1
0
forked from mirror/misskey
misskey/packages/frontend/.storybook/mocks.ts

17 lines
707 B
TypeScript
Raw Normal View History

2023-03-20 22:12:11 +09:00
import { type SharedOptions, rest } from 'msw';
export const onUnhandledRequest = ((req, print) => {
2023-04-01 16:26:08 +09:00
if (req.url.hostname !== 'localhost' || /^\/(?:client-assets\/|fluent-emojis?\/|iframe.html$|node_modules\/|src\/|sb-|static-assets\/|vite\/)/.test(req.url.pathname)) {
2023-03-20 22:12:11 +09:00
return
}
print.warning()
}) satisfies SharedOptions['onUnhandledRequest'];
export const commonHandlers = [
rest.get('/twemoji/:codepoints.svg', async (req, res, ctx) => {
const { codepoints } = req.params;
const value = await fetch(`https://unpkg.com/@discordapp/twemoji@14.1.2/dist/svg/${codepoints}.svg`).then((response) => response.blob());
return res(ctx.set('Content-Type', 'image/svg+xml'), ctx.body(value));
2023-03-20 22:12:11 +09:00
}),
];