fix: use correct spelling of attachment with Content-Disposition header (#29621)

This commit is contained in:
David Sanders 2021-06-13 19:05:16 -07:00 committed by GitHub
parent f6d673c32a
commit fed5ad5303
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -129,7 +129,7 @@ v8::Local<v8::Value> HttpResponseHeadersToV8(
!value.empty()) { !value.empty()) {
net::HttpContentDisposition header(value, std::string()); net::HttpContentDisposition header(value, std::string());
std::string decodedFilename = std::string decodedFilename =
header.is_attachment() ? " attachement" : " inline"; header.is_attachment() ? " attachment" : " inline";
decodedFilename += "; filename=" + header.filename(); decodedFilename += "; filename=" + header.filename();
value = decodedFilename; value = decodedFilename;
} }

View file

@ -18,7 +18,7 @@ describe('webRequest module', () => {
res.setHeader('Location', 'http://' + req.rawHeaders[1]); res.setHeader('Location', 'http://' + req.rawHeaders[1]);
res.end(); res.end();
} else if (req.url === '/contentDisposition') { } else if (req.url === '/contentDisposition') {
res.setHeader('content-disposition', [' attachement; filename=aa%E4%B8%ADaa.txt']); res.setHeader('content-disposition', [' attachment; filename=aa%E4%B8%ADaa.txt']);
const content = req.url; const content = req.url;
res.end(content); res.end(content);
} else { } else {
@ -306,11 +306,11 @@ describe('webRequest module', () => {
it('does not change content-disposition header by default', async () => { it('does not change content-disposition header by default', async () => {
ses.webRequest.onHeadersReceived((details, callback) => { ses.webRequest.onHeadersReceived((details, callback) => {
expect(details.responseHeaders!['content-disposition']).to.deep.equal([' attachement; filename=aa中aa.txt']); expect(details.responseHeaders!['content-disposition']).to.deep.equal([' attachment; filename=aa中aa.txt']);
callback({}); callback({});
}); });
const { data, headers } = await ajax(defaultURL + 'contentDisposition'); const { data, headers } = await ajax(defaultURL + 'contentDisposition');
expect(headers).to.match(/^content-disposition: attachement; filename=aa%E4%B8%ADaa.txt$/m); expect(headers).to.match(/^content-disposition: attachment; filename=aa%E4%B8%ADaa.txt$/m);
expect(data).to.equal('/contentDisposition'); expect(data).to.equal('/contentDisposition');
}); });