final design (#184)
* feat: redesign * feat: update other columns to new design * chore: small fixes * fix: better manage external webview * feat: redesign note * feat: update ui * chore: update * chore: update * chore: polish ui * chore: update auth ui * feat: finalize note design * chore: small fixes * feat: add window management in rust * chore: format * feat: update ui for event screen * feat: update event screen * feat: final
This commit is contained in:
35
packages/utils/src/parser.ts
Normal file
35
packages/utils/src/parser.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { IMAGES, VIDEOS } from "./constants";
|
||||
|
||||
export function parser(content: string) {
|
||||
// Get clean content
|
||||
const urls = content.match(/(https?:\/\/\S+)/gi);
|
||||
|
||||
// Extract images and videos from content
|
||||
const images: string[] = [];
|
||||
const videos: string[] = [];
|
||||
let text: string = content;
|
||||
|
||||
if (urls) {
|
||||
for (const url of urls) {
|
||||
const ext = new URL(url).pathname.split(".")[1];
|
||||
|
||||
if (IMAGES.includes(ext)) {
|
||||
text = text.replace(url, "");
|
||||
images.push(url);
|
||||
}
|
||||
|
||||
if (VIDEOS.includes(ext)) {
|
||||
text = text.replace(url, "");
|
||||
videos.push(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const trimContent = text.trim();
|
||||
|
||||
return {
|
||||
content: trimContent,
|
||||
images,
|
||||
videos,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user