From ef6ea7eeb88a2523a4285cb7409d0e1fa2c23965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 30 Aug 2024 08:34:11 +0200 Subject: [PATCH] fix: Only show url result if a valid URL is provided MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../partials/rowTypePartials/TextLinkForm.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue b/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue index bd34d2b6c..86b7a786d 100644 --- a/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue +++ b/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue @@ -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 } @@ -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,