Skip to content

Commit

Permalink
fix(links): Always pass full URLs to NcReferenceList
Browse files Browse the repository at this point in the history
See discussions here for further information:
* nextcloud-libraries/nextcloud-vue#5290
* nextcloud-libraries/nextcloud-vue#5272

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Feb 24, 2024
1 parent 81ec67c commit a18314e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/components/Link/LinkBubbleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ export default {
* NcReferenceList only accepts full URLs with origin.
*/
sanitizedHref() {
return this.href?.startsWith('/')
? location.origin + this.href
: this.href
const url = new URL(this.href, window.location)
return url.href
},
title() {
Expand Down
6 changes: 3 additions & 3 deletions src/nodes/ParagraphView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export default {
const linkMark = textNode?.marks.find((m) => m.type.name === 'link')
const href = linkMark?.attrs?.href

const PATTERN = /(^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)($)/ig
if ((new RegExp(PATTERN)).test(href)) {
return href
if (href) {
const url = new URL(href, window.location)
return url.href
}

return null
Expand Down

0 comments on commit a18314e

Please sign in to comment.