-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 cannot handle "localhost" domain for base url #26019
Comments
The current regex in validateBaseUrl expects a base url to be of the format I am not sure if the right solution is to accept all domains without domain extension or simply grant an exception for
|
Bare hosts are certainly valid URLs and accepted by URL in the browser. new URL("/home", "http://phallguy").toString() // => http://phallguy/home I don't really know why there's a custom-built URL for react-native so don't know if there are other issues to consider. Personally, I would expect feature parity with browser URL. |
If that is the case then I think the below will be a better solution
|
Bare hosts are accepted in WHATWG URL API as well, so I think it would make sense to allow it in React Native's URL constructor. https://nodejs.org/api/url.html#url_the_whatwg_url_api |
Y'all probably want to check this #25719. |
Summary: Fix for #26019 URL cannot handle "localhost" domain for base url. Also noticed another issue where `/` is not added between base URL and path if it is missing. Added fix for that too. ## Changelog [Javascript] [Fixed] - `URL`: Bare Hosts are now supported. Pull Request resolved: #26050 Test Plan: * `new URL('home', 'http://localhost')` now returns `http://localhost/home` instead of throwing an error. * `new URL('en-US/docs', 'https://developer.mozilla.org')` now returns `https://developer.mozilla.org/en-US/docs` and not `https://developer.mozilla.orgen-US/docs`. Differential Revision: D17314137 Pulled By: cpojer fbshipit-source-id: ef56c4f4032187a7efee32b28e2b3c935b6a2599
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. |
👋 You should check this out: https://github.com/charpeni/react-native-url-polyfill. |
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. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
URL constructor raises a TypeError when using
localhost
as the base url.React Native version:
System:
OS: macOS 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 4.55 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.6.0 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: ^16.9.0 => 16.9.0
react-native: 0.60.4 => 0.60.4
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
Describe what you expected to happen:
Snack, code example, screenshot, or link to a repository:
https://snack.expo.io/@phallguy/e6bc36
The text was updated successfully, but these errors were encountered: