Skip to content

Commit 9d8ab38

Browse files
committed
Fix compatibility with Ruby 3.4
But also older Rubies if the default URI parser is set to `RFC3986`.
1 parent a255895 commit 9d8ab38

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/octokit/repository.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,14 @@ def url
8181

8282
private
8383

84+
ABS_URI_REGEXP = if URI.const_defined?(:RFC2396_PARSER) # Ruby 3.4+
85+
URI::RFC2396_PARSER.regexp.fetch(:ABS_URI)
86+
else
87+
URI::RFC2396_Parser.new.regexp.fetch(:ABS_URI)
88+
end
89+
8490
def validate_owner_and_name!(repo)
85-
if @owner.include?('/') || @name.include?('/') || !url.match(URI::ABS_URI)
91+
if @owner.include?('/') || @name.include?('/') || !url.match?(ABS_URI_REGEXP)
8692
raise_invalid_repository!(repo)
8793
end
8894
end

0 commit comments

Comments
 (0)