Skip to content

Commit 254c44e

Browse files
authored
Merge pull request #6794 from nextcloud/fix/render_invalid_url
fix(link): Don't throw exception on invalid URL href
2 parents 3211411 + d182756 commit 254c44e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/marks/Link.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@ const Link = TipTapLink.extend({
6060

6161
renderHTML(options) {
6262
const { mark } = options
63-
const url = new URL(mark.attrs.href, window.location)
64-
const href = PROTOCOLS_TO_LINK_TO.includes(url.protocol)
65-
? domHref(mark, this.options.relativePath)
66-
: '#'
63+
let href
64+
try {
65+
const url = new URL(mark.attrs.href, window.location)
66+
href = PROTOCOLS_TO_LINK_TO.includes(url.protocol)
67+
? domHref(mark, this.options.relativePath)
68+
: '#'
69+
} catch (error) {
70+
href = '#'
71+
}
6772
return ['a', {
6873
...mark.attrs,
6974
href,

0 commit comments

Comments
 (0)