minor fixes

This commit is contained in:
Ren Amamiya
2023-05-07 15:16:46 +07:00
parent c39987ff1c
commit 7a10d6a3d9
5 changed files with 25 additions and 20 deletions

View File

@@ -20,12 +20,12 @@ export const noteParser = (event: Event) => {
// make sure url is trimmed
const url = item.trim();
if (url.match(/\.(jpg|jpeg|gif|png|webp|avif)$/i)) {
if (url.match(/\.(jpg|jpeg|gif|png|webp|avif)$/)) {
// image url
content.images.push(url);
// remove url from original content
content.parsed = content.parsed.replace(url, '');
} else if (url.match(/\.(mp4|webm|mov)$/i)) {
} else if (url.match(/\.(mp4|webm|mov|ogv|avi|mp3)$/)) {
// video
content.videos.push(url);
// remove url from original content
@@ -34,8 +34,8 @@ export const noteParser = (event: Event) => {
});
// map hashtag to em
content.original.match(/#(\w+)(?!:\/\/)/gi)?.forEach((item) => {
content.parsed = content.parsed.replace(item, `[${item}](https://snort.social/search/#${item})`);
content.original.match(/#(\w+)(?!:\/\/)/g)?.forEach((item) => {
content.parsed = content.parsed.replace(item, `[${item}](https://primal.net/search/${item})`);
});
// handle nostr mention