From 416dc66621849b0369b28785fa3b1beaefdc17d6 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Fri, 6 Jan 2023 12:05:27 +0100 Subject: [PATCH] feat: clickable links on about page --- src/Text.js | 88 ++++++++++++++++++++++++++++++++++++++++ src/element/Note.js | 88 +--------------------------------------- src/pages/ProfilePage.js | 3 +- 3 files changed, 92 insertions(+), 87 deletions(-) create mode 100644 src/Text.js diff --git a/src/Text.js b/src/Text.js new file mode 100644 index 000000000..7b8687322 --- /dev/null +++ b/src/Text.js @@ -0,0 +1,88 @@ +import { Link } from "react-router-dom"; + +import Invoice from "./element/Invoice"; +import { UrlRegex, FileExtensionRegex, MentionRegex, InvoiceRegex } from "./Const"; + +export function extractLinks(fragments) { + return fragments.map(f => { + if (typeof f === "string") { + return f.split(UrlRegex).map(a => { + if (a.startsWith("http")) { + try { + let url = new URL(a); + let ext = url.pathname.toLowerCase().match(FileExtensionRegex); + if (ext) { + switch (ext[1]) { + case "gif": + case "jpg": + case "jpeg": + case "png": + case "bmp": + case "webp": { + return ; + } + case "mp4": + case "mkv": + case "avi": + case "m4v": { + return