misskey/packages/frontend/.storybook/mocks.ts
Acid Chicken (硫酸鶏) 1521bb088c
build(#10336): finalize
2023-04-01 16:26:08 +09:00

17 lines
673 B
TypeScript

import { type SharedOptions, rest } from 'msw';
export const onUnhandledRequest = ((req, print) => {
if (req.url.hostname !== 'localhost' || /^\/(?:client-assets\/|fluent-emojis?\/|iframe.html$|node_modules\/|src\/|sb-|static-assets\/|vite\/)/.test(req.url.pathname)) {
return
}
print.warning()
}) satisfies SharedOptions['onUnhandledRequest'];
export const commonHandlers = [
rest.get('/twemoji/:codepoints.svg', async (req, res, ctx) => {
const { codepoints } = req.params;
const file = await import(`../node_modules/@discordapp/twemoji/dist/svg/${codepoints}.svg?raw`);
return res(ctx.set('Content-Type', 'image/svg+xml'), ctx.body(file.default));
}),
];