Created
June 4, 2012 13:37
Normalize URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<string> NormalizeUrls(List<string> urls, string rootUrl) | |
{ | |
Uri uri; | |
if (!Uri.TryCreate(rootUrl, UriKind.Absolute, out uri)) return new List<string>(); | |
return urls.Select(url => !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? string.Concat(uri.AbsoluteUri, url) : url).Distinct().ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment