Skip to content

Commit

Permalink
fix: some invalid url wrongly detected by anchorme
Browse files Browse the repository at this point in the history
url like `https://…a.com`. see alexcorvi/anchorme.js/issues/109

closes #3185
  • Loading branch information
UncleBill committed May 16, 2021
1 parent 7290b73 commit 9ba3efe
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/shared/src/utils/parseURL.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import parser from 'anchorme'
export function parseURL(string: string) {
return parser.list(string).map((x) => x.string)
return parser
.list(string)
.map((x) => x.string)
.filter((y) => {
try {
new URL(y)
return true
} catch {
return false
}
})
}

0 comments on commit 9ba3efe

Please sign in to comment.