formats.exposed/public/index/constants.js

47 lines
1.4 KiB
JavaScript
Raw Normal View History

// @ts-check
/**
* @typedef {object} MimeSniffPattern
* @prop {ArrayLike<number>} bytes The byte pattern to use for MIME sniffing, lifted from the "MIME Sniffing" spec.
* @prop {ArrayLike<number>} mask The pattern mask to use for MIME sniffing, lifted from the "MIME Sniffing" spec.
*/
/**
* @typedef {object} SupportedFileType
* @prop {string} name The English name of a file type.
* @prop {string[]} extensions File extension for this type, with the leading dot.
* @prop {string} mimeType MIME type for this file type.
* @prop {string} route The route to the file type's page.
* @prop {MimeSniffPattern[]} mimeSniffPatterns MIME sniffing patterns.
*/
/** @type {SupportedFileType[]} */
export const SUPPORTED_FILE_TYPES = [
2023-08-11 19:58:53 +00:00
{
name: "GIF",
extensions: [".gif", "image/gif"],
mimeType: "image/gif",
2023-11-10 18:06:05 +00:00
route: "gif/",
2023-08-11 19:58:53 +00:00
mimeSniffPatterns: [
{
bytes: [0x47, 0x49, 0x46, 0x38, 0x37, 0x61],
mask: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
},
{
bytes: [0x47, 0x49, 0x46, 0x38, 0x39, 0x61],
mask: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
},
],
},
{
name: "PNG",
extensions: [".png", ".apng"],
mimeType: "image/png",
2023-11-10 18:06:05 +00:00
route: "png/",
mimeSniffPatterns: [{
bytes: [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A],
mask: [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
}],
},
];