diff --git a/packages/client/src/components/MkUrlPreview.vue b/packages/client/src/components/MkUrlPreview.vue index f649405479..9241c49c36 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:", "ipfs:", "ipns:", "finger:"].includes(requestUrl.protocol)) +if (!["http:", "https:", "gopher:", "gemini:", "matrix:", "ipfs:", "ipns:", "finger:"].includes(requestUrl.protocol) && !requestUrl.protocol.startsWith("web+")) 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 75be6ccd07..e44e980054 100644 --- a/packages/client/src/components/global/MkUrl.vue +++ b/packages/client/src/components/global/MkUrl.vue @@ -46,7 +46,9 @@ const props = defineProps<{ const self = props.url.startsWith(local); const url = parseUri(props.url); -if (!["http", "https", "gopher", "gemini", "matrix", "ipfs", "ipns", "finger"].includes(url.scheme)) throw new Error("invalid url"); +if (!["http", "https", "gopher", "gemini", "matrix", "ipfs", "ipns", "finger"].includes(url.scheme) && !url.scheme.startsWith("web+")) + throw new Error("invalid url"); + const el = ref(); useTooltip(el, (showing) => { diff --git a/packages/client/src/scripts/parse-uri.ts b/packages/client/src/scripts/parse-uri.ts index 2c25766a34..3408c5f078 100644 --- a/packages/client/src/scripts/parse-uri.ts +++ b/packages/client/src/scripts/parse-uri.ts @@ -6,7 +6,7 @@ export function parseUri(uri: string): { fragment: string | null; } { const urlParts = uri.match( - /^(\w+):(\/\/)?([^/?#]*)(\/([^?#]*))?(\?([^#]*))?(#(.*))?$/, + /^([\w+]+):(\/\/)?([^/?#]*)(\/([^?#]*))?(\?([^#]*))?(#(.*))?$/, ); if (!urlParts) { diff --git a/packages/ffm-js/src/internal/parser.ts b/packages/ffm-js/src/internal/parser.ts index 4af12ce573..3dc186c4cb 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)|(ipns)|(ipfs)):\/\//), + P.regexp(/((https?)|(gemini)|(gopher)|(matrix)|(ipns)|(ipfs)|(finger)|(web\+\w+)):\/\//), 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)|(ipns)|(ipfs)):\/\//), + P.regexp(/((https?)|(gemini)|(gopher)|(matrix)|(ipns)|(ipfs)|(finger)|(web\+\w+)):\/\//), P.seq([P.notMatch(P.alt([close, space])), P.char], 1).many(1), close, ]).text();