Skip to content

Commit

Permalink
test: better
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Nov 28, 2023
1 parent 9d4d9ba commit da71e49
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/fetch/data-uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,19 @@ test('https://domain.com/?', (t) => {
t.equal(serialized, domain)
})

// https://github.com/nodejs/undici/issues/2474
test('hash url', (t) => {
t.plan(1)
const domain = 'https://domain.com/#a#b'
const url = new URL(domain)
const serialized = URLSerializer(url, true)
t.equal(serialized, url.href.substring(0, url.href.length - url.hash.length))
})

// https://github.com/nodejs/undici/issues/2474
test('data url that includes the hash', async (t) => {
t.plan(2)
t.plan(1)
const dataURL = 'data:,node#js#'
const serialized = URLSerializer(new URL(dataURL), true)
t.equal('data:,node', serialized)
try {
const res = await fetch(dataURL)
t.equal(await res.text(), 'node')
Expand Down

0 comments on commit da71e49

Please sign in to comment.