Added ipfs and web+

This commit is contained in:
Sal Rahman 2023-08-21 06:31:53 -07:00
parent 1122b5130f
commit c210269181
4 changed files with 7 additions and 5 deletions

View file

@ -135,7 +135,7 @@ const embedId = `embed${Math.random().toString().replace(/\D/, "")}`;
let tweetHeight = ref(150); let tweetHeight = ref(150);
const requestUrl = new URL(props.url); 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"); throw new Error("invalid url");
if ( if (

View file

@ -46,7 +46,9 @@ const props = defineProps<{
const self = props.url.startsWith(local); const self = props.url.startsWith(local);
const url = parseUri(props.url); 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(); const el = ref();
useTooltip(el, (showing) => { useTooltip(el, (showing) => {

View file

@ -6,7 +6,7 @@ export function parseUri(uri: string): {
fragment: string | null; fragment: string | null;
} { } {
const urlParts = uri.match( const urlParts = uri.match(
/^(\w+):(\/\/)?([^/?#]*)(\/([^?#]*))?(\?([^#]*))?(#(.*))?$/, /^([\w+]+):(\/\/)?([^/?#]*)(\/([^?#]*))?(\?([^#]*))?(#(.*))?$/,
); );
if (!urlParts) { if (!urlParts) {

View file

@ -674,7 +674,7 @@ export const language = P.createLanguage({
])); ]));
const parser = P.seq([ const parser = P.seq([
notLinkLabel, notLinkLabel,
P.regexp(/((https?)|(gemini)|(gopher)|(matrix)|(ipns)|(ipfs)):\/\//), P.regexp(/((https?)|(gemini)|(gopher)|(matrix)|(ipns)|(ipfs)|(finger)|(web\+\w+)):\/\//),
innerItem.many(1).text(), innerItem.many(1).text(),
]); ]);
return new P.Parser<M.MfmUrl | string>((input, index, state) => { return new P.Parser<M.MfmUrl | string>((input, index, state) => {
@ -706,7 +706,7 @@ export const language = P.createLanguage({
const parser = P.seq([ const parser = P.seq([
notLinkLabel, notLinkLabel,
open, 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), P.seq([P.notMatch(P.alt([close, space])), P.char], 1).many(1),
close, close,
]).text(); ]).text();