mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-30 00:51:30 +08:00
refactor(server/utils): merge sanitizeFilenameForHeader into getContentDisposition
sanitizeFilenameForHeader is not used anywhere else and is tiny, so let's merge it
This commit is contained in:
parent
29b1befd60
commit
fedaec6c79
@ -117,15 +117,10 @@ export async function crash() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sanitizeFilenameForHeader(filename: string) {
|
|
||||||
const sanitizedFilename = sanitize(filename).trim() || "file";
|
|
||||||
return encodeURIComponent(sanitizedFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getContentDisposition(filename: string) {
|
export function getContentDisposition(filename: string) {
|
||||||
const sanitizedFilename = sanitizeFilenameForHeader(filename);
|
const sanitizedFilename = sanitize(filename).trim() || "file";
|
||||||
|
const uriEncodedFilename = encodeURIComponent(sanitizedFilename);
|
||||||
return `file; filename="${sanitizedFilename}"; filename*=UTF-8''${sanitizedFilename}`;
|
return `file; filename="${uriEncodedFilename}"; filename*=UTF-8''${uriEncodedFilename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// render and book are string note in the sense that they are expected to contain empty string
|
// render and book are string note in the sense that they are expected to contain empty string
|
||||||
@ -325,7 +320,6 @@ export default {
|
|||||||
removeDiacritic,
|
removeDiacritic,
|
||||||
removeTextFileExtension,
|
removeTextFileExtension,
|
||||||
replaceAll,
|
replaceAll,
|
||||||
sanitizeFilenameForHeader,
|
|
||||||
sanitizeSqlIdentifier,
|
sanitizeSqlIdentifier,
|
||||||
stripTags,
|
stripTags,
|
||||||
timeLimit,
|
timeLimit,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user