URL incorrectly adds trailing slash
See original GitHub issue🐛 Bug Report
URL
polyfill in React Native
0.59 is broken because it’s not compliant to WHATWG URL Standard. And it’s broken even for the simplest use cases.
To Reproduce
const url = new URL('https://facebook.github.io/react-native/img/header_logo.png');
console.log(url);
Expected Behavior
https://facebook.github.io/react-native/img/header_logo.png
Actual Behavior
https://facebook.github.io/react-native/img/header_logo.png/
Note the trailing slash causes the URL points to a 404 page.
Environment
React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 823.64 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.0
Yarn: 1.15.2
npm: 6.5.0
Watchman: 4.9.0
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 28
Build Tools: 28.0.3
System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.4 => 0.59.4
Possible Cause
This code was introduced in https://github.com/facebook/react-native/pull/22901 .
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:13 (5 by maintainers)
Top Results From Across the Web
How to fix internal redirects from trailing slash mismatch?
This issue means that the one URL on your site is redirected to another internal URL. The presence/absence of a trailing slash is...
Read more >sometimes incorrectly appends slash on URLs (when both ...
Chrome add a slash at the end of the URL, resulting on a wrong parameter: ... the fact that the route may have...
Read more >Trailing Slashes and SEO - Best Practice Guide
Historically, a trailing slash marked a directory and a URL without a trailing slash at the end used to mean that the URL...
Read more >When should I use a trailing slash in my URL?
No trailing slash is helpful for working with relative sub-paths AND also trailing slash is improper when the url denotes a resource. So...
Read more >What Is a Trailing Slash in URL & How Does It Affect SEO?
Every SEO specialist needs to deal with duplicate content on a regular basis. Sometimes, it turns out that inappropriate use of the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
👋 You should check this out: https://github.com/charpeni/react-native-url-polyfill.
I’ll second this issue, having to add a goofy workaround