Skip to content

Commit

Permalink
🐛[RUMF-403] fix checkURLSupported (#302)
Browse files Browse the repository at this point in the history
URL api was never used and for customer with base-uri csp restrictions, the polyfill raised an exception.
cf [bug report](#294 (comment))

Add similar restrictions to e2e pages.
  • Loading branch information
bcaudan authored Mar 16, 2020
1 parent 0536d59 commit 3301647
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/urlPolyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function getHash(url: string) {

function buildUrl(url: string, base?: string) {
if (checkURLSupported()) {
return new URL(url, base)
return base !== undefined ? new URL(url, base) : new URL(url)
}
if (base === undefined && !/:/.test(url)) {
throw new Error(`Invalid URL: '${url}'`)
Expand All @@ -59,8 +59,9 @@ function checkURLSupported() {
return isURLSupported
}
try {
const url = new URL('http://test')
return url.href === 'http://test'
const url = new URL('http://test/path')
isURLSupported = url.href === 'http://test/path'
return isURLSupported
} catch {
isURLSupported = false
}
Expand Down
1 change: 1 addition & 0 deletions test/static/async-e2e-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="base-uri 'none';" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" href="/empty.css" />
<title>async tests page</title>
Expand Down
1 change: 1 addition & 0 deletions test/static/bundle-e2e-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="base-uri 'none';" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" href="/empty.css" />
<title>bundle tests page</title>
Expand Down
1 change: 1 addition & 0 deletions test/static/npm-e2e-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="base-uri 'none';" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" href="/empty.css" />
<title>npm tests page</title>
Expand Down

0 comments on commit 3301647

Please sign in to comment.