From 9d8ab38001f42a994f4366ed5f4d75bc9a7c77ef Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 23 Jul 2024 13:02:15 +0200 Subject: [PATCH] Fix compatibility with Ruby 3.4 But also older Rubies if the default URI parser is set to `RFC3986`. --- lib/octokit/repository.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/octokit/repository.rb b/lib/octokit/repository.rb index c6524cef1..9dba454c3 100644 --- a/lib/octokit/repository.rb +++ b/lib/octokit/repository.rb @@ -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