fix(externalLinks): make external link warning work with subpaths

This commit is contained in:
Philip Molares
2026-07-22 20:14:44 +02:00
committed by GitHub
parent c77d64ad6e
commit 1a7c27470e
2 changed files with 3 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
- Added external link whitelist setting (`externalLinkWhitelist` in config.json or `CMD_EXTERNAL_LINK_WHITELIST`) to skip warning page for certain domains
- Added external link warning setting (`externalLinkWarning` in config.json or `CMD_EXTERNAL_LINK_WARNING`) to disable the external link warning page entirely
- Fixed external link warning for subpath instances
- Enabled `.webp` for file uploads (for all backends but `imgur`, since it does not support it)
### Bugfixes

View File

@@ -624,7 +624,8 @@ export function rewriteExternalLinks (view) {
return
}
const noteURL = window.location.pathname.split('/').pop()
anchor.attr('href', `${window.location.origin}/_link?url=${encodeURIComponent(parsed.href)}&note=${noteURL}`)
const urlPath = window.urlpath ? `/${window.urlpath}` : ''
anchor.attr('href', `${window.location.origin}${urlPath}/_link?url=${encodeURIComponent(parsed.href)}&note=${noteURL}`)
})
}
window.rewriteExternalLinks = rewriteExternalLinks