Skip to content
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: Do not prepend baseUrl if the URL is not a relative URL #26009

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions Libraries/Blob/URL.js
Expand Up @@ -130,7 +130,12 @@ export class URL {

constructor(url: string, base: string) {
let baseUrl = null;
if (base) {
if (!base || validateBaseUrl(url)) {
this._url = url;
if (!this._url.endsWith('/')) {
this._url += '/';
}
} else {
if (typeof base === 'string') {
baseUrl = base;
if (!validateBaseUrl(baseUrl)) {
Expand All @@ -146,11 +151,6 @@ export class URL {
url = '';
}
this._url = `${baseUrl}${url}`;
} else {
this._url = url;
if (!this._url.endsWith('/')) {
this._url += '/';
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Libraries/Blob/__tests__/URL-test.js
Expand Up @@ -31,5 +31,7 @@ describe('URL', function() {
// expect(g.href).toBe('https://developer.mozilla.org/en-US/docs');
const h = new URL('/en-US/docs', a);
expect(h.href).toBe('https://developer.mozilla.org/en-US/docs');
const i = new URL('http://github.com', 'http://google.com');
expect(i.href).toBe('http://github.com/');
});
});