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 6f199e2
Showing 1 changed file with 12 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,15 @@ export default {
this.setProviderLoading(providerId, false)
},
isValidUrl(string) {
try {
new URL(string);

Check failure on line 234 in src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Do not use 'new' for side effects

Check failure on line 234 in src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Extra semicolon
return true;

Check failure on line 235 in src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Extra semicolon
} catch (err) {
return false;

Check failure on line 237 in src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue

View workflow job for this annotation

GitHub Actions / NPM lint

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

0 comments on commit 6f199e2

Please sign in to comment.