Skip to content

Commit 24aa144

Browse files
committed
fix(LinkBubbleView): Don't choke on invalid URLs
Fixes "TypeError: URL constructor: ... is not a valid URL." Fixes: #6841 Signed-off-by: Jonas <jonas@freesources.org>
1 parent a0fa51b commit 24aa144

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/components/Link/LinkBubbleView.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,25 @@ export default {
147147
* NcReferenceList only accepts full URLs with origin.
148148
*/
149149
sanitizedHref() {
150-
const url = new URL(this.href, window.location)
151-
return url.href
150+
try {
151+
const url = new URL(this.href, window.location)
152+
return url.href
153+
} catch {
154+
return this.href
155+
}
152156
},
153157
154158
title() {
155159
return this.referenceTitle ? this.referenceTitle : this.sanitizedHref
156160
},
157161
158162
showPreview() {
159-
const url = new URL(this.href, window.location)
160-
return this.href && PROTOCOLS_WITH_PREVIEW.includes(url.protocol)
163+
try {
164+
const url = new URL(this.href, window.location)
165+
return this.href && PROTOCOLS_WITH_PREVIEW.includes(url.protocol)
166+
} catch {
167+
return false
168+
}
161169
},
162170
},
163171

0 commit comments

Comments
 (0)