Files
klz-cables.com/.pnpm-store/v10/files/37/88322d18fd5da362f2128dfff209cf66c4aabb620d75d90002ba3aa95b7fd46a5051ae00cc42402db91e56e07a829b0c781f6b9e91d2667dbd34fd11832e1c
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

40 lines
1.1 KiB
Plaintext

import type { FileInfo } from "../types/index.js";
import type { Plugin } from "../types/index.js";
const BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
export default {
/**
* The order that this parser will run, in relation to other parsers.
*/
order: 400,
/**
* Whether to allow "empty" files (zero bytes).
*/
allowEmpty: true,
/**
* Determines whether this parser can parse a given file reference.
* Parsers that return true will be tried, in order, until one successfully parses the file.
* Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
* every parser will be tried.
*/
canParse(file: FileInfo) {
// Use this parser if the file is a Buffer, and has a known binary extension
return Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url);
},
/**
* Parses the given data as a Buffer (byte array).
*/
parse(file: FileInfo) {
if (Buffer.isBuffer(file.data)) {
return file.data;
} else {
// This will reject if data is anything other than a string or typed array
return Buffer.from(file.data);
}
},
} as Plugin;