diff --git a/src/lsfnd.ts b/src/lsfnd.ts index 94d8e04..ce745bb 100644 --- a/src/lsfnd.ts +++ b/src/lsfnd.ts @@ -245,7 +245,14 @@ export async function ls( + (Array.isArray(options) ? 'array' : typeof options)); } - // Resolve its absolute and relative path + // Check and resolve the `rootDir` option + if (options.rootDir && (options.rootDir instanceof URL + || (typeof options.rootDir === 'string' && /^[a-zA-Z]+:/.test(options.rootDir)) + )) { + options.rootDir = fileUrlToPath(options.rootDir); + } + + // Resolve the absolute and relative of the dirpath argument absdirpath = path.isAbsolute( dirpath) ? dirpath : path.posix.resolve( dirpath); diff --git a/types/index.d.ts b/types/index.d.ts index 0ee1cb7..3c0c51b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -130,7 +130,7 @@ export declare interface LsOptions { * @defaultValue `'.'` or `process.cwd()` * @since 1.0.0 */ - rootDir?: StringPath | undefined; + rootDir?: StringPath | URL | undefined; /** * Determines whether to return absolute paths for all entries. * @@ -249,7 +249,7 @@ export declare interface DefaultLsOptions { readonly recursive: false; readonly match: RegExp; readonly exclude: undefined; - readonly rootDir: StringPath; + readonly rootDir: StringPath | URL; readonly absolute: false; readonly basename: false; }