iceshrimp-161sh/packages/backend/src/misc/content-disposition.ts

10 lines
235 B
TypeScript
Raw Normal View History

2023-01-13 05:40:33 +01:00
import cd from "content-disposition";
2023-01-13 05:40:33 +01:00
export function contentDisposition(
type: "inline" | "attachment",
filename: string,
): string {
const fallback = filename.replace(/[^\w.-]/g, "_");
return cd(filename, { type, fallback });
}