Hello im experiencing an issue with Regex when hitting an api endpoint

Viewed 32

Below is the code that i am using for fluent validation:

        RuleFor(x => x.Domain).Matches("^(?!(http://|https://|www.|-))([a-z0-9-._~]*){1,63}$");     
        RuleFor(x => x.Domain).NotNull().NotEmpty();
        RuleFor(x => x.Path).Matches("^[a-z0-9/]*$");
        RuleFor(x => x.Path).NotEmpty().NotNull();
        RuleFor(x => x.Target).Matches("^((http://|https://|-))([a-z0-9-._~]*){1,63}$"); 
        RuleFor(x => x.Target).NotEmpty().NotNull();

Exception - System.ArgumentException: 'Error updating redirect 2. The RegEx engine has timed out while trying to match a pattern to an input string. This can occur for many reasons, including very large inputs or excessive backtracking caused by nested quantifiers, back-references and other factors.'

Is there anything wrong with my REGEX that may be causing this error? I am also hitting other endpoints which is using the exact same rule for "domain" however that gives me a status code of 200.

If you require any further info please let me know!

Thanks!

0 Answers
Related