MrMistreater

Normalize URLs

Apr 13th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.31 KB | None | 0 0
  1. public static List<string> NormalizeUrls(List<string> urls, string rootUrl)
  2. {
  3.     Uri uri;
  4.     if (!Uri.TryCreate(rootUrl, UriKind.Absolute, out uri)) return new List<string>();
  5.     return urls.Select(url => !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? string.Concat(uri.AbsoluteUri, url) : url).Distinct().ToList();
  6. }
Advertisement
Add Comment
Please, Sign In to add comment