Skip to content

Commit f97e365

Browse files
committed
Content-Security-Policy: base-uri
1 parent 1450d90 commit f97e365

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

middleware/policy.es

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ const
5757
// script-src fallback
5858
= Array.from (scripts)
5959

60+
, bases // base-uri
61+
// default-src fallback
62+
= Array.from (defaults)
63+
64+
6065
, directives = [
6166
// Reporting directives
6267
`report-to ${ reports.join ` ` }`
@@ -74,7 +79,7 @@ const
7479
, `worker-src ${ workers.join ` ` }`
7580

7681
// Document directives
77-
// , `base-uri ${ bases.join ` ` }`
82+
, `base-uri ${ bases.join ` ` }`
7883
// , `sandbox ${ sandboxes.join ` ` }`
7984
// , `plugin-types ${ plugins.join ` ` }`
8085

middleware/policy.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,24 @@ test ("Content-Security-Policy: worker-src", async t => {
230230
})
231231

232232

233+
test ("Content-Security-Policy: base-uri", async t => {
234+
235+
const
236+
server = (new Server).serve ``
237+
238+
, response = await
239+
fetch ('http://localhost:8181/')
240+
241+
, policy = response.headers.get ('content-security-policy')
242+
243+
244+
t.ok ( policy.includes (`base-uri ${defaults}`) )
245+
246+
server.close ``
247+
t.end ()
248+
})
249+
250+
233251
test ("Content-Security-Policy: block-all-mixed-content", async t => {
234252

235253
const

0 commit comments

Comments
 (0)