Skip to content

Instantly share code, notes, and snippets.

@Dynyx
Created June 4, 2012 13:37
Normalize URL
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