Skip to content

Commit

Permalink
fix(core): allow BaseService#root_url to be an Addressable::URI (#17895)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasdower authored Feb 23, 2024
1 parent 6f7d2a6 commit acb1097
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions google-apis-core/lib/google/apis/core/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ def universe_domain= new_ud
end

# Root URL (host/port) for the API
# @return [Addressable::URI]
# @return [Addressable::URI, String]
attr_reader :root_url

# Set the root URL.
# If the given url includes a universe domain substitution, it is
# resolved in the current universe domain
#
# @param url_or_template [String] The URL, which can include a universe domain substitution
# @param url_or_template [Addressable::URI, String] The URL, which can include a universe domain substitution
def root_url= url_or_template
if url_or_template.include? ENDPOINT_SUBSTITUTION
if url_or_template.is_a?(String) && url_or_template.include?(ENDPOINT_SUBSTITUTION)
@root_url_template = url_or_template
@root_url = url_or_template.gsub ENDPOINT_SUBSTITUTION, universe_domain
else
Expand Down
5 changes: 5 additions & 0 deletions google-apis-core/spec/google/apis/core/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@
expect(service_ud.root_url).to eql "https://endpoint1.mydomain5.com/"
end

it "should support setting root url to Addressable::URI" do
service_ud.root_url = Addressable::URI.parse("https://endpoint1.mydomain5.com/")
expect(service_ud.root_url).to be_a(Addressable::URI)
end

it "should support setting root url to a dynamic value" do
service.universe_domain = "mydomain6.com"
service.root_url = "https://endpoint2.$UNIVERSE_DOMAIN$/"
Expand Down

0 comments on commit acb1097

Please sign in to comment.