Skip to content

Commit 527184b

Browse files
authored
Merge pull request #7869 from nextcloud/backport/7864/stable31
[stable31] fix(LinkBubbleView): Don't choke on invalid URLs
2 parents 5e374d6 + 7e01ef1 commit 527184b

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)