From d3de14c2a17dc65d73f73fbed95364561f82a1b1 Mon Sep 17 00:00:00 2001 From: Sal Rahman Date: Mon, 14 Aug 2023 04:37:21 -0700 Subject: [PATCH] Done --- packages/client/src/components/MkUrlPreview.vue | 2 +- packages/client/src/components/global/MkUrl.vue | 2 +- packages/ffm-js/src/internal/parser.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/MkUrlPreview.vue b/packages/client/src/components/MkUrlPreview.vue index e7a141339d..fe5c37b0d3 100644 --- a/packages/client/src/components/MkUrlPreview.vue +++ b/packages/client/src/components/MkUrlPreview.vue @@ -135,7 +135,7 @@ const embedId = `embed${Math.random().toString().replace(/\D/, "")}`; let tweetHeight = ref(150); const requestUrl = new URL(props.url); -if (!["http:", "https:", "gopher:", "gemini:", "matrix:"].includes(requestUrl.protocol)) +if (!["http:", "https:", "gopher:", "gemini:", "matrix:", "ipfs:", "ipns:"].includes(requestUrl.protocol)) throw new Error("invalid url"); if ( diff --git a/packages/client/src/components/global/MkUrl.vue b/packages/client/src/components/global/MkUrl.vue index 9e6c29f68d..0f0b2b7cda 100644 --- a/packages/client/src/components/global/MkUrl.vue +++ b/packages/client/src/components/global/MkUrl.vue @@ -45,7 +45,7 @@ const props = defineProps<{ const self = props.url.startsWith(local); const url = new URL(props.url); -if (!["http:", "https:", "gopher:", "gemini:", "matrix:"].includes(url.protocol)) throw new Error("invalid url"); +if (!["http:", "https:", "gopher:", "gemini:", "matrix:", "ipfs:", "ipns:"].includes(url.protocol)) throw new Error("invalid url"); const el = ref(); useTooltip(el, (showing) => { diff --git a/packages/ffm-js/src/internal/parser.ts b/packages/ffm-js/src/internal/parser.ts index e37bbcde44..4af12ce573 100644 --- a/packages/ffm-js/src/internal/parser.ts +++ b/packages/ffm-js/src/internal/parser.ts @@ -674,7 +674,7 @@ export const language = P.createLanguage({ ])); const parser = P.seq([ notLinkLabel, - P.regexp(/((https?)|(gemini)|(gopher)|(matrix)):\/\//), + P.regexp(/((https?)|(gemini)|(gopher)|(matrix)|(ipns)|(ipfs)):\/\//), innerItem.many(1).text(), ]); return new P.Parser((input, index, state) => { @@ -706,7 +706,7 @@ export const language = P.createLanguage({ const parser = P.seq([ notLinkLabel, open, - P.regexp(/((https?)|(gemini)|(gopher)|(matrix)):\/\//), + P.regexp(/((https?)|(gemini)|(gopher)|(matrix)|(ipns)|(ipfs)):\/\//), P.seq([P.notMatch(P.alt([close, space])), P.char], 1).many(1), close, ]).text();