* Selfhosting Twemoji * ちっ * うざっ * あ * add test Co-authored-by: mei23 <m@m544.net>
This commit is contained in:
parent
1143606bc8
commit
5cf07fc50f
5 changed files with 66 additions and 2 deletions
|
@ -1 +1 @@
|
|||
export const twemojiSvgBase = 'https://twemoji.maxcdn.com/v/latest/svg';
|
||||
export const twemojiSvgBase = '/twemoji';
|
||||
|
|
|
@ -101,6 +101,22 @@ router.get('/apple-touch-icon.png', async ctx => {
|
|||
});
|
||||
});
|
||||
|
||||
router.get('/twemoji/(.*)', async ctx => {
|
||||
const path = ctx.path.replace('/twemoji/', '');
|
||||
|
||||
if (!path.match(/^[0-9a-f-]+\.svg$/)) {
|
||||
ctx.status = 404;
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.set('Content-Security-Policy', `default-src 'none'; style-src 'unsafe-inline'`);
|
||||
|
||||
await send(ctx as any, path, {
|
||||
root: `${_dirname}/../../../node_modules/@discordapp/twemoji/dist/svg/`,
|
||||
maxage: ms('30 days'),
|
||||
});
|
||||
});
|
||||
|
||||
// ServiceWorker
|
||||
router.get('/sw.js', async ctx => {
|
||||
await send(ctx as any, `/sw.${config.version}.js`, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue