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

feat!: Standardize baseURL to URL’s spec #600

Merged
merged 4 commits into from
Oct 29, 2024
Merged

Conversation

danielbankhead
Copy link
Contributor

@danielbankhead danielbankhead commented Feb 1, 2024

Notable Changes

  • Remove long-deprecated baseUrl
  • Use proper base URL logic via new URL(url, base)

This will align us with the standard way to resolve relative-to-base URLs.

Background: https://developer.mozilla.org/en-US/docs/Web/API/URL_API/Resolving_relative_references

Migration Guide

The expected resolved URL can be determined via:

new URL(opts.url, opts.baseURL);

Example

Resolving to https://example.com/v1/mango:

  • old:
const gaxios = new Gaxios({baseURL: `https://example.com/v1`});
const res = await gaxios.request({url: '/mango'});
  • new:
const gaxios = new Gaxios({baseURL: `https://example.com/v1/`}); // note the ending `/`
const res = await gaxios.request({url: 'mango'}); // note the lack of leading `/`

Notice how the new functionality would allow easy access to https://example.com/mango as well by providing {url: '/mango'} (with the leading /).

🦕

- Remove long-deprecated `baseUrl`
- Use proper `base` URL logic via `new URL(url, base)`
@danielbankhead danielbankhead requested a review from a team as a code owner February 1, 2024 03:51
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Feb 1, 2024
Copy link

Warning: This pull request is touching the following templated files:

@danielbankhead danielbankhead added semver: major Hint for users that this is an API breaking change. next major: breaking change this is a change that we should wait to bundle into the next major version do not merge Indicates a pull request not ready for merge, due to either quality or timing. and removed size: s Pull request size is small. labels Feb 1, 2024
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Feb 16, 2024
@danielbankhead danielbankhead changed the title feat!: Standardize baseURL feat!: Standardize baseURL to URL’s spec Oct 11, 2024
@danielbankhead danielbankhead removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 25, 2024
@danielbankhead danielbankhead requested a review from a team as a code owner October 29, 2024 21:18
@danielbankhead danielbankhead merged commit ffff324 into main Oct 29, 2024
14 checks passed
@danielbankhead danielbankhead deleted the standardize-baseurl branch October 29, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next major: breaking change this is a change that we should wait to bundle into the next major version semver: major Hint for users that this is an API breaking change. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants