Skip to content

Commit

Permalink
Merge pull request #5272 from nextcloud-libraries/fix/reference_full_url
Browse files Browse the repository at this point in the history
fix(NcReferenceList): Resolve relative URLs before fetching references
  • Loading branch information
mejo- authored Feb 20, 2024
2 parents a3cd2e4 + 0b3f4ef commit 71740f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/NcRichText/NcReferenceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export default {
richObjectType: 'open-graph',
}
},
fullUrl() {
return new URL(this.text.trim(), window.location)
},
},
watch: {
text: 'fetch',
Expand All @@ -97,7 +100,7 @@ export default {
return
}
if (!(new RegExp(URL_PATTERN).exec(this.text))) {
if (!(new RegExp(URL_PATTERN).exec(this.fullUrl.href))) {
this.loading = false
return
}
Expand All @@ -113,7 +116,7 @@ export default {
})
},
resolve() {
const match = (new RegExp(URL_PATTERN).exec(this.text.trim()))
const match = (new RegExp(URL_PATTERN).exec(this.fullUrl.href))
if (this.limit === 1 && match) {
return axios.get(generateOcsUrl('references/resolve', 2) + `?reference=${encodeURIComponent(match[0])}`)
}
Expand Down

0 comments on commit 71740f8

Please sign in to comment.