Skip to content

Commit 85c29ac

Browse files
committed
fix(core): ensure all file paths use forward slashes in windows
1 parent 5fdf685 commit 85c29ac

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

Diff for: .changeset/evil-goats-begin.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-markdown': patch
3+
---
4+
5+
- Ensure all file paths use forward slashes in windows (#782).

Diff for: packages/typedoc-plugin-markdown/src/libs/utils/get-file-path.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export function getFilePath(filePathWithExtension: string) {
77
if (!filePathWithExtension) {
88
return '';
99
}
10-
return path.join(
10+
const filePath = path.join(
1111
path.dirname(filePathWithExtension),
1212
path.basename(filePathWithExtension, path.extname(filePathWithExtension)),
1313
);
14+
return filePath.replace(/\\/g, '/');
1415
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
import * as path from 'path';
2-
31
export function replaceFilename(originalPath: string, newFileName: string) {
4-
const normalizedPath = originalPath.replace(/\\/g, '/');
5-
const updatedPath = normalizedPath.replace(
6-
/\/[^/]+(\.[^/.]+)$/,
7-
`${path.sep}${newFileName}$1`,
8-
);
9-
return path.sep === '\\' ? updatedPath.replace(/\//g, '\\') : updatedPath;
2+
return originalPath
3+
.replace(/\\/g, '/')
4+
.replace(/\/[^/]+(\.[^/.]+)$/, `/${newFileName}$1`);
105
}

Diff for: packages/typedoc-plugin-markdown/src/router/routers/member-router.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { removeFirstScopedDirectory } from '@plugin/libs/utils/index.js';
1+
import {
2+
removeFirstScopedDirectory,
3+
replaceFilename,
4+
} from '@plugin/libs/utils/index.js';
25
import { MarkdownRenderer } from '@plugin/types/markdown-renderer.js';
36
import * as path from 'path';
47
import {
@@ -28,12 +31,6 @@ export class KindStructureRouter extends MarkdownRouter {
2831
if (this.isPackages) {
2932
const meta = (this.application.renderer as MarkdownRenderer)
3033
?.packagesMeta[reflection.name];
31-
const replaceFilename = (originalPath: string, newFileName: string) => {
32-
return originalPath.replace(
33-
/\/[^/]+(\.[^/.]+)$/,
34-
`/${newFileName}$1`,
35-
);
36-
};
3734
if (
3835
meta &&
3936
(reflection as DeclarationReflection).readme &&
@@ -132,6 +129,7 @@ export class KindStructureRouter extends MarkdownRouter {
132129
}
133130
let fullName = path
134131
.join([dir, fileName].filter((part) => !!part).join('/'))
132+
.replace(/\\/g, '/')
135133
.replace(/ /g, '-');
136134

137135
if (this.ignoreScopes) {

Diff for: packages/typedoc-plugin-markdown/src/router/routers/module-router.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
removeFirstScopedDirectory,
3+
replaceFilename,
34
toPascalCase,
45
} from '@plugin/libs/utils/index.js';
56
import { MarkdownRenderer } from '@plugin/types/markdown-renderer.js';
@@ -31,12 +32,6 @@ export class ModuleRouter extends MarkdownRouter {
3132
if (this.isPackages) {
3233
const meta = (this.application.renderer as MarkdownRenderer)
3334
?.packagesMeta[reflection.name];
34-
const replaceFilename = (originalPath: string, newFileName: string) => {
35-
return originalPath.replace(
36-
/\/[^/]+(\.[^/.]+)$/,
37-
`/${newFileName}$1`,
38-
);
39-
};
4035
if (
4136
meta &&
4237
(reflection as DeclarationReflection).readme &&
@@ -132,6 +127,7 @@ export class ModuleRouter extends MarkdownRouter {
132127
}
133128
let fullName = path
134129
.join([dir, fileName].filter((part) => !!part).join('/'))
130+
.replace(/\\/g, '/')
135131
.replace(/ /g, '-');
136132
if (this.ignoreScopes) {
137133
fullName = removeFirstScopedDirectory(fullName);

0 commit comments

Comments
 (0)