From 470e6d61b001f86de13be85510744dc63971e7a1 Mon Sep 17 00:00:00 2001 From: jeswinsimon Date: Sat, 10 Aug 2019 12:22:48 +0530 Subject: [PATCH 1/3] URL: Do not prepend baseUrl if the URL is not a relative URL --- Libraries/Blob/URL.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Libraries/Blob/URL.js b/Libraries/Blob/URL.js index 692980c69ca1b8..601c6609393b5d 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -130,7 +130,13 @@ 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 +152,6 @@ export class URL { url = ''; } this._url = `${baseUrl}${url}`; - } else { - this._url = url; - if (!this._url.endsWith('/')) { - this._url += '/'; - } } } From 326f3d5626f25668fe0255d0f7fa0ea7df3bb2ac Mon Sep 17 00:00:00 2001 From: jeswinsimon Date: Sat, 10 Aug 2019 12:34:39 +0530 Subject: [PATCH 2/3] Lint error fixes --- Libraries/Blob/URL.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Libraries/Blob/URL.js b/Libraries/Blob/URL.js index 601c6609393b5d..9869dcbeaded11 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -130,13 +130,12 @@ export class URL { constructor(url: string, base: string) { let baseUrl = null; - if(!base || validateBaseUrl(url)) { + if (!base || validateBaseUrl(url)) { this._url = url; if (!this._url.endsWith('/')) { this._url += '/'; } - } - else { + } else { if (typeof base === 'string') { baseUrl = base; if (!validateBaseUrl(baseUrl)) { From 05bdfd8a512fb59b469423bc5b8715c1553c4d2b Mon Sep 17 00:00:00 2001 From: jeswinsimon Date: Mon, 12 Aug 2019 22:29:56 +0530 Subject: [PATCH 3/3] Added test --- Libraries/Blob/__tests__/URL-test.js | 2 ++ 1 file changed, 2 insertions(+) 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/'); }); });