Skip to content

Commit

Permalink
Fix compatibility with Ruby 3.4
Browse files Browse the repository at this point in the history
But also older Rubies if the default URI parser is set
to `RFC3986`.
  • Loading branch information
byroot committed Jul 23, 2024
1 parent a255895 commit 9d8ab38
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/octokit/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ def url

private

ABS_URI_REGEXP = if URI.const_defined?(:RFC2396_PARSER) # Ruby 3.4+
URI::RFC2396_PARSER.regexp.fetch(:ABS_URI)
else
URI::RFC2396_Parser.new.regexp.fetch(:ABS_URI)
end

def validate_owner_and_name!(repo)
if @owner.include?('/') || @name.include?('/') || !url.match(URI::ABS_URI)
if @owner.include?('/') || @name.include?('/') || !url.match?(ABS_URI_REGEXP)
raise_invalid_repository!(repo)
end
end
Expand Down

0 comments on commit 9d8ab38

Please sign in to comment.