diff --git a/CHANGELOG.md b/CHANGELOG.md index fe510ef9b..913f63623 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ title: Changelog - Fix restoration of groups/categories including documents, #2801. - Fixed missed relative paths within markdown link references in documents. - Improved handling of incomplete inline code blocks within markdown. +- Direct `https://` links under the `hostedBaseUrl` option's URL will no + longer be treated as external, #2809. ### Thanks! diff --git a/src/lib/output/components.ts b/src/lib/output/components.ts index e0e410a91..59f184009 100644 --- a/src/lib/output/components.ts +++ b/src/lib/output/components.ts @@ -41,7 +41,7 @@ export abstract class ContextAwareRendererComponent extends RendererComponent { */ protected urlPrefix = /^(http|ftp)s?:\/\//; - private get hostedBaseUrl() { + protected get hostedBaseUrl() { const url = this.application.options.getValue("hostedBaseUrl"); return !url || url.endsWith("/") ? url : url + "/"; } diff --git a/src/lib/output/themes/MarkedPlugin.tsx b/src/lib/output/themes/MarkedPlugin.tsx index 0289dfefd..49420b12c 100644 --- a/src/lib/output/themes/MarkedPlugin.tsx +++ b/src/lib/output/themes/MarkedPlugin.tsx @@ -332,7 +332,11 @@ export class MarkedPlugin extends ContextAwareRendererComponent { // will be relative links. This will likely have to change with // the introduction of support for customized routers whenever // that becomes a real thing. - if (this.markdownLinkExternal && /https?:\/\//i.test(href)) { + if ( + this.markdownLinkExternal && + /https?:\/\//i.test(href) && + !(href + "/").startsWith(this.hostedBaseUrl) + ) { token.attrSet("target", "_blank"); const classes = token.attrGet("class")?.split(" ") || []; classes.push("external");