< Summary

Class:DCL.MyAccount.LinkValidator
Assembly:MyAccountHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/LinkValidator.cs
Covered lines:0
Uncovered lines:2
Coverable lines:2
Total lines:19
Line coverage:0% (0 of 2)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:2
Method coverage:0% (0 of 2)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LinkValidator()0%2100%
IsValid(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/MyAccountHUD/LinkValidator.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2
 3namespace 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    {
 010        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>
 017        public static bool IsValid(string url) => httpRegex.IsMatch(url);
 18    }
 19}