First commit: /a/, /gallery/, images, gifv

This commit is contained in:
3nprob
2021-10-06 18:43:59 +09:00
commit 7c2e53c6e4
19 changed files with 6559 additions and 0 deletions

11
src/util.ts Normal file
View File

@@ -0,0 +1,11 @@
export const proxyURL = (url: string): string =>
url.replace(/^https?:\/\/[^.]*\.imgur.com\//, '/');
export const linkify = (content: string) =>
content.replace(
/https?:\/\/[^.]*\.imgur.com\/([\/_a-zA-Z0-9-]+)\.gifv/g,
'<video src="/$1.mp4" class="commentVideo commentObject" loop="" autoplay=""></video>'
).replace(
/https?:\/\/[^.]*\.imgur.com\/([\/_a-zA-Z0-9-]+\.[a-z0-9A-Z]{2,6})/g,
'<a href="/$1" target="_blank"><img class="commentImage commentObject" src="/$1" loading="lazy" /></a>'
);