diff --git a/packages/shared/src/utils/parseURL.ts b/packages/shared/src/utils/parseURL.ts index 982e6ee9a42f..8d8bae97e548 100644 --- a/packages/shared/src/utils/parseURL.ts +++ b/packages/shared/src/utils/parseURL.ts @@ -1,4 +1,15 @@ import parser from 'anchorme' -export function parseURL(string: string) { - return parser.list(string).map((x) => x.string) +export function parseURL(text: string) { + return parser + .list(text) + .map((x) => x.string) + .filter((y) => { + // See https://github.com/alexcorvi/anchorme.js/issues/109 + try { + new URL(y) + return true + } catch { + return false + } + }) }