Skip to content

Commit 7f499cc

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Fix URL parsing to respect node/chromium convention (#50757)
Summary: We received [this issue](#50747) in OSS where the URL parsing logic does not respect node/chromium specs. This can cause issue in usercode. This change fixes it ## Changelog: [General][Fixed] - make sure that URLs are parsed following the node specs Differential Revision: D73101813
1 parent b880d47 commit 7f499cc

File tree

1 file changed

+13
-1
lines changed
  • packages/react-native/Libraries/Blob

1 file changed

+13
-1
lines changed

packages/react-native/Libraries/Blob/URL.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,19 @@ export class URL {
8181
let baseUrl = null;
8282
if (!base || validateBaseUrl(url)) {
8383
this._url = url;
84-
if (!this._url.endsWith('/')) {
84+
if (this._url.includes('#')) {
85+
const split = this._url.split('#');
86+
const beforeHash = split[0];
87+
const website = beforeHash.split('://')[1];
88+
if (!website.includes('/')) {
89+
this._url = split.join('/#');
90+
}
91+
}
92+
93+
if (
94+
!this._url.endsWith('/') &&
95+
!(this._url.includes('?') || this._url.includes('#'))
96+
) {
8597
this._url += '/';
8698
}
8799
} else {

0 commit comments

Comments
 (0)