diff --git a/web/components/UpdateOs/ChangelogModal.vue b/web/components/UpdateOs/ChangelogModal.vue index 87198c68e..f4f2a26da 100644 --- a/web/components/UpdateOs/ChangelogModal.vue +++ b/web/components/UpdateOs/ChangelogModal.vue @@ -42,6 +42,32 @@ const showExternalChangelogLink = computed(() => { const showExtendKeyButton = computed(() => { return availableWithRenewal.value; }); + +// find all the links in the changelog and make them open in a new tab +const changelogOutput = ref(null); +const updateChangelogLinks = () => { + if (!changelogOutput.value) { return; } + const links = changelogOutput.value.querySelectorAll('a'); + links.forEach((link) => { + link.setAttribute('target', '_blank'); + link.setAttribute('rel', 'noopener noreferrer'); + /** @todo what do we do with docusaurus based links? May also be broken on the account app. */ + // if a link is a relative link or doesn't start with http but doesn't start with a # we need to prepend the base url of the changelog + // const linkIsRelative = link.getAttribute('href')?.startsWith('/') ?? false; + // const linkIsNotHttp = link.getAttribute('href')?.startsWith('http') === false; + // const linkIsNotHash = link.getAttribute('href')?.startsWith('#') === false; + // const linkIsNotAnchor = link.getAttribute('href')?.startsWith('mailto') === false; + // if (linkIsRelative || (linkIsNotHttp && linkIsNotHash && linkIsNotAnchor)) { + // link.setAttribute('href', `${releaseForUpdate.value?.changelog}${link.getAttribute('href')}`); + // } + }); +}; + +watchEffect(() => { + if (mutatedParsedChangelog.value) { + updateChangelogLinks(); + } +});