| | 1 | | using System.Text.RegularExpressions; |
| | 2 | |
|
| | 3 | | namespace DCL.MyAccount |
| | 4 | | { |
| | 5 | | /// <summary> |
| | 6 | | /// A helper class to validate urls. These must start either with http or https. |
| | 7 | | /// </summary> |
| | 8 | | public static class LinkValidator |
| | 9 | | { |
| 0 | 10 | | private static readonly Regex httpRegex = new (@"^(?:https?):\/\/[^\s\/$.?#].[^\s]*$"); |
| | 11 | |
|
| | 12 | | /// <summary> |
| | 13 | | /// Validates a given url checking if it starts with http or https. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="url">The url to validate.</param> |
| | 16 | | /// <returns>Whether the url is valid or not.</returns> |
| 0 | 17 | | public static bool IsValid(string url) => httpRegex.IsMatch(url); |
| | 18 | | } |
| | 19 | | } |