Skip to content

Commit b7673f2

Browse files
authored
Merge pull request #171 from kopischke/fix/sanitizePath
Fix findParentNodeModules failing on paths with non-URI legal chars
2 parents eb61208 + 9398b85 commit b7673f2

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

packages/doxdox-cli/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { promises as fs } from 'fs';
66

77
import { dirname, join } from 'path';
88

9+
import { fileURLToPath } from 'url';
10+
911
import { globby } from 'globby';
1012

1113
import updateNotifier from 'update-notifier';
@@ -19,8 +21,7 @@ import doxdox, {
1921
getRootDirPath,
2022
loadPlugin,
2123
parseConfigFromCLI,
22-
parseIgnoreConfig,
23-
sanitizePath
24+
parseIgnoreConfig
2425
} from 'doxdox-core';
2526

2627
import { Doc, File } from 'doxdox-core';
@@ -113,7 +114,7 @@ const overridePackage = String(
113114
const cliConfig = parseConfigFromCLI(args.raw);
114115

115116
const nodeModulesDir = await findParentNodeModules(
116-
dirname(sanitizePath(import.meta.url))
117+
dirname(fileURLToPath(import.meta.url))
117118
);
118119

119120
if (!nodeModulesDir) {

packages/doxdox-core/src/utils.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
isFile,
1212
parseConfigFromCLI,
1313
parseIgnoreConfig,
14-
sanitizePath,
1514
slugify
1615
} from './utils';
1716

@@ -169,18 +168,6 @@ describe('utils', () => {
169168
});
170169
});
171170

172-
describe('sanitizePath', () => {
173-
it('sanitize path', () => {
174-
expect(
175-
sanitizePath(
176-
'file:///Users/scottdoxey/git/github/doxdox/packages/doxdox-cli/dist/src/index.js'
177-
)
178-
).toEqual(
179-
'/Users/scottdoxey/git/github/doxdox/packages/doxdox-cli/dist/src/index.js'
180-
);
181-
});
182-
});
183-
184171
describe('slugify', () => {
185172
it('slugify path', () => {
186173
expect(slugify('./src/utils.ts')).toEqual('src-utils-ts');

packages/doxdox-core/src/utils.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,6 @@ export const parseIgnoreConfig = (contents: string): string[] =>
189189
.filter(line => line.trim())
190190
.map(line => `!${line.trim().replace(/^!/, '')}`);
191191

192-
/**
193-
* Sanitizes given path or url.
194-
*
195-
* @param {string} [url] Path or url.
196-
* @return {Promise<string>} Sanitized path.
197-
* @public
198-
*/
199-
200-
export const sanitizePath = (path: string): string => new URL(path).pathname;
201-
202192
/**
203193
* Slugify a value for use as an anchor.
204194
*

0 commit comments

Comments
 (0)