Skip to content

URL with base is always used, even when absolute URL is provided #26006

Closed
@phallguy

Description

@phallguy

MDN documentation for URL states that the base should only be used when url is a relative url. However the current implementation of URL (as of 0.60.4) in react-native always prepends the base if given.

React Native version:

System:
OS: macOS 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 447.55 MB / 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

const url = new URL("http://github.com", "http://google.com")
console.log(url.toString()) // => "http://google.comhttp://github.com"

Describe what you expected to happen:

const url = new URL("http://github.com", "http://google.com")
console.log(url.toString()) // => "http://github.com"

Snack, code example, screenshot, or link to a repository:

https://snack.expo.io/@phallguy/url-bug-report

Notice that if you view the snack with the "Web" preview, it is handled correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions