Skip to content

Commit acb1097

Browse files
fix(core): allow BaseService#root_url to be an Addressable::URI (#17895)
1 parent 6f7d2a6 commit acb1097

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

google-apis-core/lib/google/apis/core/base_service.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,16 @@ def universe_domain= new_ud
119119
end
120120

121121
# Root URL (host/port) for the API
122-
# @return [Addressable::URI]
122+
# @return [Addressable::URI, String]
123123
attr_reader :root_url
124124

125125
# Set the root URL.
126126
# If the given url includes a universe domain substitution, it is
127127
# resolved in the current universe domain
128128
#
129-
# @param url_or_template [String] The URL, which can include a universe domain substitution
129+
# @param url_or_template [Addressable::URI, String] The URL, which can include a universe domain substitution
130130
def root_url= url_or_template
131-
if url_or_template.include? ENDPOINT_SUBSTITUTION
131+
if url_or_template.is_a?(String) && url_or_template.include?(ENDPOINT_SUBSTITUTION)
132132
@root_url_template = url_or_template
133133
@root_url = url_or_template.gsub ENDPOINT_SUBSTITUTION, universe_domain
134134
else

google-apis-core/spec/google/apis/core/service_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@
533533
expect(service_ud.root_url).to eql "https://endpoint1.mydomain5.com/"
534534
end
535535

536+
it "should support setting root url to Addressable::URI" do
537+
service_ud.root_url = Addressable::URI.parse("https://endpoint1.mydomain5.com/")
538+
expect(service_ud.root_url).to be_a(Addressable::URI)
539+
end
540+
536541
it "should support setting root url to a dynamic value" do
537542
service.universe_domain = "mydomain6.com"
538543
service.root_url = "https://endpoint2.$UNIVERSE_DOMAIN$/"

0 commit comments

Comments
 (0)