UrlChecker.cs 445 B

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