diff --git a/Libraries/Blob/URL.js b/Libraries/Blob/URL.js index 692980c69ca1b8..9869dcbeaded11 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -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)) { @@ -146,11 +151,6 @@ export class URL { url = ''; } this._url = `${baseUrl}${url}`; - } else { - this._url = url; - if (!this._url.endsWith('/')) { - this._url += '/'; - } } } diff --git a/Libraries/Blob/__tests__/URL-test.js b/Libraries/Blob/__tests__/URL-test.js index 8ca71feb025315..281649ce7821d7 100644 --- a/Libraries/Blob/__tests__/URL-test.js +++ b/Libraries/Blob/__tests__/URL-test.js @@ -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/'); }); });