Skip to content

Commit d9ec2dd

Browse files
committed
Treat links under hostedBaseUrl as internal
Resolves #2809
1 parent 8acc237 commit d9ec2dd

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ title: Changelog
1919
- Fix restoration of groups/categories including documents, #2801.
2020
- Fixed missed relative paths within markdown link references in documents.
2121
- Improved handling of incomplete inline code blocks within markdown.
22+
- Direct `https://` links under the `hostedBaseUrl` option's URL will no
23+
longer be treated as external, #2809.
2224

2325
### Thanks!
2426

src/lib/output/components.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export abstract class ContextAwareRendererComponent extends RendererComponent {
4141
*/
4242
protected urlPrefix = /^(http|ftp)s?:\/\//;
4343

44-
private get hostedBaseUrl() {
44+
protected get hostedBaseUrl() {
4545
const url = this.application.options.getValue("hostedBaseUrl");
4646
return !url || url.endsWith("/") ? url : url + "/";
4747
}

src/lib/output/themes/MarkedPlugin.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,11 @@ export class MarkedPlugin extends ContextAwareRendererComponent {
332332
// will be relative links. This will likely have to change with
333333
// the introduction of support for customized routers whenever
334334
// that becomes a real thing.
335-
if (this.markdownLinkExternal && /https?:\/\//i.test(href)) {
335+
if (
336+
this.markdownLinkExternal &&
337+
/https?:\/\//i.test(href) &&
338+
!(href + "/").startsWith(this.hostedBaseUrl)
339+
) {
336340
token.attrSet("target", "_blank");
337341
const classes = token.attrGet("class")?.split(" ") || [];
338342
classes.push("external");

0 commit comments

Comments
 (0)