-
Notifications
You must be signed in to change notification settings - Fork 25k
Closed
Labels
Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.Newer Patch AvailableResolution: FixedA PR that fixes this issue has been merged.A PR that fixes this issue has been merged.Resolution: PR SubmittedA pull request with a fix has been provided.A pull request with a fix has been provided.
Description
Description
The window.URL object is available in Hermes but is otherwise un-implemented. All of the accessors have todo Errors.
react-native/packages/react-native/Libraries/Blob/URL.js
Lines 140 to 230 in 43d69ee
| constructor(url: string, base: string | URL) { | |
| let baseUrl = null; | |
| if (!base || validateBaseUrl(url)) { | |
| this._url = url; | |
| if (!this._url.endsWith('/')) { | |
| this._url += '/'; | |
| } | |
| } else { | |
| if (typeof base === 'string') { | |
| baseUrl = base; | |
| if (!validateBaseUrl(baseUrl)) { | |
| throw new TypeError(`Invalid base URL: ${baseUrl}`); | |
| } | |
| } else { | |
| baseUrl = base.toString(); | |
| } | |
| if (baseUrl.endsWith('/')) { | |
| baseUrl = baseUrl.slice(0, baseUrl.length - 1); | |
| } | |
| if (!url.startsWith('/')) { | |
| url = `/${url}`; | |
| } | |
| if (baseUrl.endsWith(url)) { | |
| url = ''; | |
| } | |
| this._url = `${baseUrl}${url}`; | |
| } | |
| } | |
| get hash(): string { | |
| throw new Error('URL.hash is not implemented'); | |
| } | |
| get host(): string { | |
| throw new Error('URL.host is not implemented'); | |
| } | |
| get hostname(): string { | |
| throw new Error('URL.hostname is not implemented'); | |
| } | |
| get href(): string { | |
| return this.toString(); | |
| } | |
| get origin(): string { | |
| throw new Error('URL.origin is not implemented'); | |
| } | |
| get password(): string { | |
| throw new Error('URL.password is not implemented'); | |
| } | |
| get pathname(): string { | |
| throw new Error('URL.pathname not implemented'); | |
| } | |
| get port(): string { | |
| throw new Error('URL.port is not implemented'); | |
| } | |
| get protocol(): string { | |
| throw new Error('URL.protocol is not implemented'); | |
| } | |
| get search(): string { | |
| throw new Error('URL.search is not implemented'); | |
| } | |
| get searchParams(): URLSearchParams { | |
| if (this._searchParamsInstance == null) { | |
| this._searchParamsInstance = new URLSearchParams(); | |
| } | |
| return this._searchParamsInstance; | |
| } | |
| toJSON(): string { | |
| return this.toString(); | |
| } | |
| toString(): string { | |
| if (this._searchParamsInstance === null) { | |
| return this._url; | |
| } | |
| // $FlowFixMe[incompatible-use] | |
| const instanceString = this._searchParamsInstance.toString(); | |
| const separator = this._url.indexOf('?') > -1 ? '&' : '?'; | |
| return this._url + separator + instanceString; | |
| } | |
| get username(): string { |
Steps to reproduce
const urlObj = new window.URL( validUrlString );
urlObj.hostname
// Error: URL.hostname is not implemented
React Native Version
0.73.6
Affected Platforms
Runtime - Android
Output of npx react-native info
Reproducible on all systems. The code has a baked-in Error and no implementation.
Stacktrace or Logs
This error is located at:
in SecureContext (created by Connect(SecureContext))
in Connect(SecureContext) (created by App)
in RCTView (created by View)
in View (created by App)
in App (created by RenderApp)
in Provider (created by RenderApp)
in RenderApp
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in app(RootComponent), js engine: hermes
Reproducer
https://snack.expo.dev/O0xP_moxLBNEHK9bXAXKl
It can't be reproduced in a browser folks. It can only be seen on hermes/Android so this is moot.
Screenshots and Videos
No response
x64Eddie
Metadata
Metadata
Assignees
Labels
Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.Newer Patch AvailableResolution: FixedA PR that fixes this issue has been merged.A PR that fixes this issue has been merged.Resolution: PR SubmittedA pull request with a fix has been provided.A pull request with a fix has been provided.