UrlChecker.cs 506 B

123456789101112131415161718192021222324
  1. using System.Text.RegularExpressions;
  2. namespace ShwasherSys.Views
  3. {
  4. public static class UrlChecker
  5. {
  6. private static readonly Regex UrlWithProtocolRegex = new Regex("^.{1,10}://.*$");
  7. public static bool IsRooted(string url)
  8. {
  9. if (url.StartsWith("/"))
  10. {
  11. return true;
  12. }
  13. if (UrlWithProtocolRegex.IsMatch(url))
  14. {
  15. return true;
  16. }
  17. return false;
  18. }
  19. }
  20. }