diff --git a/src/path.ts b/src/path.ts index 99c9c0a..a61bee0 100644 --- a/src/path.ts +++ b/src/path.ts @@ -201,7 +201,7 @@ export const relative: typeof path.relative = function (from, to) { // dirname export const dirname: typeof path.dirname = function (p) { - return normalizeWindowsPath(p).replace(/\/$/, '').split('/').slice(0, -1).join('/') || '/' + return normalizeWindowsPath(p).replace(/\/$/, '').split('/').slice(0, -1).join('/') || (isAbsolute(p) ? '/' : '.') } // format diff --git a/test/index.spec.ts b/test/index.spec.ts index 1e25697..d1e6048 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -44,6 +44,7 @@ runTest('basename', basename, [ runTest('dirname', dirname, { // POSIX + 'test.html': '.', '/temp/': '/', '/temp/myfile.html': '/temp', './myfile.html': '.',