Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): allow BaseService#root_url to be an Addressable::URI #17895

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading