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

URL implementation should add a trailing slash to the base #25717

Closed
charpeni opened this issue Jul 18, 2019 · 4 comments
Closed

URL implementation should add a trailing slash to the base #25717

charpeni opened this issue Jul 18, 2019 · 4 comments
Labels
Bug Contributor A React Native contributor. JavaScript 🌐Networking Related to a networking API. Resolution: Backlog An issue that should be solved at some point, but it's not in the immediate roadmap. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@charpeni
Copy link
Contributor

React Native version:

System:
    OS: macOS 10.14.5
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 1002.17 MB / 32.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 27.0.3, 28.0.2, 28.0.3, 29.0.0
      System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: 17.2.4988734
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.3 => 0.60.3

The current custom implementation of URL Standard incorrectly handles conjunctions between URL and base.

constructor(url: string, base: string) {
let baseUrl = null;
if (base) {
if (typeof base === 'string') {
baseUrl = base;
if (!validateBaseUrl(baseUrl)) {
throw new TypeError(`Invalid base URL: ${baseUrl}`);
}
} else if (typeof base === 'object') {
baseUrl = base.toString();
}
if (baseUrl.endsWith('/') && url.startsWith('/')) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
}
if (baseUrl.endsWith(url)) {
url = '';
}
this._url = `${baseUrl}${url}`;
} else {
this._url = url;
if (!this._url.endsWith('/')) {
this._url += '/';
}
}
}

Steps To Reproduce

const url = new URL('about', 'https://www.mozilla.org');
console.log(url.href);

Expected Behavior

https://www.mozilla.org/about

Actual Behavior

https://www.mozilla.orgabout
@facebook-github-bot facebook-github-bot added the Contributor A React Native contributor. label Jul 18, 2019
@charpeni charpeni added the 🌐Networking Related to a networking API. label Jul 18, 2019
@charpeni
Copy link
Contributor Author

Another issue related to this:

Steps To Reproduce

const url = new URL('dev', 'https://google.dev');
console.log(url.href);

Expected Behavior

https://google.dev/dev

Actual Behavior

https://google.dev

@stale
Copy link

stale bot commented Oct 16, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 16, 2019
@charpeni charpeni added Resolution: Backlog An issue that should be solved at some point, but it's not in the immediate roadmap. and removed Stale There has been a lack of activity on this issue and it may be closed soon. labels Oct 16, 2019
@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 13, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Contributor A React Native contributor. JavaScript 🌐Networking Related to a networking API. Resolution: Backlog An issue that should be solved at some point, but it's not in the immediate roadmap. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
2 participants