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 f781141
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions 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)
export function parseURL(text: string) {
return parser
.list(text)
.map((x) => x.string)
.filter((y) => {
try {
new URL(y)
return true
} catch {
return false
}
})
}

0 comments on commit f781141

Please sign in to comment.