Skip to content

Commit

Permalink
fix: Only show url result if a valid URL is provided
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Aug 30, 2024
1 parent cd41c6b commit ef6ea7e
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ export default {
this.removeResultsByProviderId(providerId)

if (providerId === 'url') {
this.addUrlResult(term)
if (this.isValidUrl(term)) {
this.addUrlResult(term)
}
this.setProviderLoading(providerId, false)
return
}
Expand Down Expand Up @@ -227,6 +229,14 @@ export default {
this.setProviderLoading(providerId, false)
},

isValidUrl(string) {
try {
return new URL(string)
} catch (err) {
return false
}
},

addUrlResult(term) {
this.results.push({
title: term,
Expand Down

0 comments on commit ef6ea7e

Please sign in to comment.