Skip to content

Commit

Permalink
Allow colons in regex check, e.g. for a specific URL
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-hampton committed Nov 3, 2022
1 parent abee97b commit defa3b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion checksit/rules/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def check(self, rule_lookup, value, context=None, label=""):
errors.append(f"{label} Value '{value}' is not of required type: '{type_rule}'.")

elif rule_lookup.startswith("regex:"):
pattern = rule_lookup.split(":")[1]
pattern = ':'.join(rule_lookup.split(":")[1:]) # in case pattern has colons in it, e.g. a URL
if not re.match(f"^{pattern}$", value):
errors.append(f"{label} Value '{value}' does not match regular expression: '{pattern}'.")

Expand Down

0 comments on commit defa3b1

Please sign in to comment.