Skip to content

Commit

Permalink
add unsafe-url referrerPolicy test (#3772)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored Oct 25, 2024
1 parent c8dc113 commit eac8ed4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/fetch/issue-3767.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict'

const { once } = require('node:events')
const { createServer } = require('node:http')
const { test } = require('node:test')
const { fetch } = require('../..')
const { tspl } = require('@matteo.collina/tspl')

// https://github.com/nodejs/undici/issues/3767
test('referrerPolicy unsafe-url is respected', async (t) => {
const { completed, deepEqual } = tspl(t, { plan: 1 })

const referrer = 'https://google.com/hello/world'

const server = createServer((req, res) => {
deepEqual(req.headers.referer, referrer)

res.end()
}).listen(0)

t.after(server.close.bind(server))
await once(server, 'listening')

await fetch(`http://localhost:${server.address().port}`, {
referrer,
referrerPolicy: 'unsafe-url'
})

await completed
})

0 comments on commit eac8ed4

Please # to comment.