diff --git a/.changeset/six-spiders-sell.md b/.changeset/six-spiders-sell.md new file mode 100644 index 000000000..20aeeda2b --- /dev/null +++ b/.changeset/six-spiders-sell.md @@ -0,0 +1,5 @@ +--- +'typedoc-plugin-markdown': patch +--- + +- Fix missing slash when public path is prefixed with http (#688) diff --git a/packages/typedoc-plugin-markdown/src/theme/markdown-themeContext.ts b/packages/typedoc-plugin-markdown/src/theme/markdown-themeContext.ts index fab7212da..399a7fb63 100644 --- a/packages/typedoc-plugin-markdown/src/theme/markdown-themeContext.ts +++ b/packages/typedoc-plugin-markdown/src/theme/markdown-themeContext.ts @@ -138,7 +138,10 @@ export class MarkdownThemeContext { const publicPath = this.options.getValue('publicPath'); if (publicPath && !ignorePublicPath) { - return encodeURI(path.join(publicPath, url).replace(/\\/g, '/')); + return encodeURI(`${publicPath.replace(/\/$/, '')}/${url}`).replace( + /\\/g, + '/', + ); } const baseUrl = path.relative( diff --git a/packages/typedoc-plugin-markdown/test/fixtures/config.ts b/packages/typedoc-plugin-markdown/test/fixtures/config.ts index abb9b2314..44bd7979e 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/config.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/config.ts @@ -152,7 +152,7 @@ const config: Record = { { useHTMLAnchors: true, preserveAnchorCasing: true, - publicPath: 'http://example.com', + publicPath: 'https://example.com', sanitizeComments: true, flattenOutputFiles: true, enumMembersFormat: 'htmlTable', diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap index 23feca1df..8fd9a2a86 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/comments.spec.ts.snap @@ -351,7 +351,7 @@ exports[`Comments should get tables for properties: (Output File Strategy "membe ## Extends -- [\`BaseClassProperties\`](http:/example.com/Class.BaseClassProperties.md) +- [\`BaseClassProperties\`](https://example.com/Class.BaseClassProperties.md) ## Constructors @@ -359,15 +359,15 @@ exports[`Comments should get tables for properties: (Output File Strategy "membe ### new ClassPropertiesTable() -> **new ClassPropertiesTable**(): [\`ClassPropertiesTable\`](http:/example.com/Class.ClassPropertiesTable.md) +> **new ClassPropertiesTable**(): [\`ClassPropertiesTable\`](https://example.com/Class.ClassPropertiesTable.md) #### Returns -[\`ClassPropertiesTable\`](http:/example.com/Class.ClassPropertiesTable.md) +[\`ClassPropertiesTable\`](https://example.com/Class.ClassPropertiesTable.md) #### Inherited from -[\`BaseClassProperties\`](http:/example.com/Class.BaseClassProperties.md).[\`constructor\`](http:/example.com/Class.BaseClassProperties.md#Constructors) +[\`BaseClassProperties\`](https://example.com/Class.BaseClassProperties.md).[\`constructor\`](https://example.com/Class.BaseClassProperties.md#Constructors) ## Properties