Skip to content

Commit 7e01ef1

Browse files
mejo-backportbot[bot]
authored andcommitted
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 c73419b commit 7e01ef1

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
@@ -173,17 +173,25 @@ export default {
173173
* NcReferenceList only accepts full URLs with origin.
174174
*/
175175
sanitizedHref() {
176-
const url = new URL(this.href, window.location)
177-
return url.href
176+
try {
177+
const url = new URL(this.href, window.location)
178+
return url.href
179+
} catch {
180+
return this.href
181+
}
178182
},
179183
180184
title() {
181185
return this.referenceTitle ? this.referenceTitle : this.sanitizedHref
182186
},
183187
184188
showPreview() {
185-
const url = new URL(this.href, window.location)
186-
return this.href && PROTOCOLS_WITH_PREVIEW.includes(url.protocol)
189+
try {
190+
const url = new URL(this.href, window.location)
191+
return this.href && PROTOCOLS_WITH_PREVIEW.includes(url.protocol)
192+
} catch {
193+
return false
194+
}
187195
},
188196
},
189197

0 commit comments

Comments
 (0)