15 lines
534 B
JavaScript
15 lines
534 B
JavaScript
|
import { Stats } from 'node:fs';
|
||
|
import { format, parse } from '@tinyhttp/content-type';
|
||
|
import { eTag } from '@tinyhttp/etag';
|
||
|
export const createETag = (body, encoding) => {
|
||
|
if (body instanceof Stats) {
|
||
|
return eTag(body, { weak: true });
|
||
|
}
|
||
|
return eTag(!Buffer.isBuffer(body) ? Buffer.from(body, encoding) : body, { weak: true });
|
||
|
};
|
||
|
export function setCharset(type, charset) {
|
||
|
const parsed = parse(type);
|
||
|
parsed.parameters.charset = charset;
|
||
|
return format(parsed);
|
||
|
}
|
||
|
//# sourceMappingURL=utils.js.map
|