Skip to content

Commit ef6ea7e

Browse files
committed
fix: Only show url result if a valid URL is provided
Signed-off-by: Julius Härtl <[email protected]>
1 parent cd41c6b commit ef6ea7e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ export default {
196196
this.removeResultsByProviderId(providerId)
197197
198198
if (providerId === 'url') {
199-
this.addUrlResult(term)
199+
if (this.isValidUrl(term)) {
200+
this.addUrlResult(term)
201+
}
200202
this.setProviderLoading(providerId, false)
201203
return
202204
}
@@ -227,6 +229,14 @@ export default {
227229
this.setProviderLoading(providerId, false)
228230
},
229231
232+
isValidUrl(string) {
233+
try {
234+
return new URL(string)
235+
} catch (err) {
236+
return false
237+
}
238+
},
239+
230240
addUrlResult(term) {
231241
this.results.push({
232242
title: term,

0 commit comments

Comments
 (0)