Skip to content

Commit

Permalink
Merge pull request #6796 from nextcloud/backport/6794/stable30
Browse files Browse the repository at this point in the history
[stable30] fix(link): Don't throw exception on invalid URL href
  • Loading branch information
mejo- authored Dec 17, 2024
2 parents ffa9b6b + 005b208 commit bee20ee
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/marks/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ const Link = TipTapLink.extend({

renderHTML(options) {
const { mark } = options
const url = new URL(mark.attrs.href, window.location)
const href = PROTOCOLS_TO_LINK_TO.includes(url.protocol)
? domHref(mark, this.options.relativePath)
: '#'
let href
try {
const url = new URL(mark.attrs.href, window.location)
href = PROTOCOLS_TO_LINK_TO.includes(url.protocol)
? domHref(mark, this.options.relativePath)
: '#'
} catch (error) {
href = '#'
}
return ['a', {
...mark.attrs,
href,
Expand Down

0 comments on commit bee20ee

Please sign in to comment.