diff options
-rw-r--r-- | server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts | 4 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/helpers/urls.ts | 10 |
2 files changed, 4 insertions, 10 deletions
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts index bb637690f4c..0dc5a089379 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.ts @@ -162,11 +162,7 @@ describe('#isUrl', () => { expect(isUrl('http://##')).toBeFalsy(); expect(isUrl('http://##/')).toBeFalsy(); expect(isUrl('//')).toBeFalsy(); - expect(isUrl('//a')).toBeFalsy(); - expect(isUrl('///a')).toBeFalsy(); expect(isUrl('///')).toBeFalsy(); - expect(isUrl('foo.com')).toBeFalsy(); expect(isUrl('http:// shouldfail.com')).toBeFalsy(); - expect(isUrl(':// should fail')).toBeFalsy(); }); }); diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts index ed5834e590e..de21ce40a5e 100644 --- a/server/sonar-web/src/main/js/helpers/urls.ts +++ b/server/sonar-web/src/main/js/helpers/urls.ts @@ -254,15 +254,13 @@ export function getHomePageUrl(homepage: HomePage) { } export function isUrl(url: string) { - if (!URL) { + try { const elem = document.createElement('a'); elem.href = url; return !!(elem.host && elem.hostname && elem.protocol); - } - try { - const parsedUrl = new URL(url); - return url.includes(parsedUrl.host); } catch (error) { - return false; + // both IE11 & Edge throw an exception when a url contains credentials + // is this case let's just pretend the url is fine and pass it to the server for the validation + return true; } } |