Skip to content

Commit

Permalink
Check for constant presence
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-gordon committed Jan 3, 2025
1 parent ace52e6 commit 321d0e2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/dry/logic/predicates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,16 @@ def uuid_v7?(input) = format?(UUIDv7, input)

def uuid_v8?(input) = format?(UUIDv8, input)

def uri?(schemes, input)
uri_format = ::URI::RFC2396_PARSER.make_regexp(schemes)
format?(uri_format, input)
if defined?(::URI::RFC2396_PARSER)
def uri?(schemes, input)
uri_format = ::URI::RFC2396_PARSER.make_regexp(schemes)
format?(uri_format, input)
end
else
def uri?(schemes, input)
uri_format = ::URI::DEFAULT_PARSER.make_regexp(schemes)
format?(uri_format, input)
end
end

def uri_rfc3986?(input) = format?(::URI::RFC3986_Parser::RFC3986_URI, input)
Expand Down

0 comments on commit 321d0e2

Please sign in to comment.