Skip to content

Commit

Permalink
Merge pull request #6794 from nextcloud/fix/render_invalid_url
Browse files Browse the repository at this point in the history
fix(link): Don't throw exception on invalid URL href
  • Loading branch information
mejo- authored Dec 17, 2024
2 parents 3211411 + d182756 commit 254c44e
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 254c44e

Please sign in to comment.