Merge pull request #51684 from fabianzw/master

fix(files): Properly encode URLs when preparing ZIP download
pull/51761/head
John Molakvoæ 2025-03-27 12:05:19 +07:00 committed by GitHub
commit 96e25558d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

@ -55,15 +55,15 @@ const downloadNodes = function(nodes: Node[]) {
url.searchParams.append('accept', 'zip')
}
} else {
url = new URL(nodes[0].source)
url = new URL(nodes[0].encodedSource)
let base = url.pathname
for (const node of nodes.slice(1)) {
base = longestCommonPath(base, (new URL(node.source).pathname))
base = longestCommonPath(base, (new URL(node.encodedSource).pathname))
}
url.pathname = base
// The URL contains the path encoded so we need to decode as the query.append will re-encode it
const filenames = nodes.map((node) => decodeURI(node.encodedSource.slice(url.href.length + 1)))
const filenames = nodes.map((node) => decodeURIComponent(node.encodedSource.slice(url.href.length + 1)))
url.searchParams.append('accept', 'zip')
url.searchParams.append('files', JSON.stringify(filenames))
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long