Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ async function * convertIterableToBuffer (iterable) {
}
}

/** @type {globalThis['ReadableStream']} */
let ReadableStream
function ReadableStreamFrom (iterable) {
if (!ReadableStream) {
Expand Down Expand Up @@ -395,9 +396,9 @@ function ReadableStreamFrom (iterable) {
},
async cancel (reason) {
await iterator.return()
}
},
0
},
type: 'bytes'
}
)
}

Expand Down
6 changes: 3 additions & 3 deletions lib/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function extractBody (object, keepalive = false) {
stream = object.stream()
} else {
// 4. Otherwise, set stream to a new ReadableStream object, and set
// up stream.
// up stream with byte reading support.
stream = new ReadableStream({
async pull (controller) {
controller.enqueue(
Expand All @@ -56,7 +56,7 @@ function extractBody (object, keepalive = false) {
queueMicrotask(() => readableStreamClose(controller))
},
start () {},
type: undefined
type: 'bytes'
})
}

Expand Down Expand Up @@ -237,7 +237,7 @@ function extractBody (object, keepalive = false) {
async cancel (reason) {
await iterator.return()
},
type: undefined
type: 'bytes'
})
}

Expand Down
8 changes: 7 additions & 1 deletion lib/fetch/dataURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ function URLSerializer (url, excludeFragment = false) {
const href = url.href
const hashLength = url.hash.length

return hashLength === 0 ? href : href.substring(0, href.length - hashLength)
const serialized = hashLength === 0 ? href : href.substring(0, href.length - hashLength)

if (!hashLength && href.endsWith('#')) {
return serialized.slice(0, -1)
}

return serialized
}

// https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points
Expand Down
Loading