Skip to content

Commit 321d0e2

Browse files
committed
Check for constant presence
1 parent ace52e6 commit 321d0e2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/dry/logic/predicates.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,16 @@ def uuid_v7?(input) = format?(UUIDv7, input)
185185

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

188-
def uri?(schemes, input)
189-
uri_format = ::URI::RFC2396_PARSER.make_regexp(schemes)
190-
format?(uri_format, input)
188+
if defined?(::URI::RFC2396_PARSER)
189+
def uri?(schemes, input)
190+
uri_format = ::URI::RFC2396_PARSER.make_regexp(schemes)
191+
format?(uri_format, input)
192+
end
193+
else
194+
def uri?(schemes, input)
195+
uri_format = ::URI::DEFAULT_PARSER.make_regexp(schemes)
196+
format?(uri_format, input)
197+
end
191198
end
192199

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

0 commit comments

Comments
 (0)