@flex-development/pathe
Version:
Universal drop-in replacement for node:path
28 lines (27 loc) • 881 B
JavaScript
import { DRIVE_PATH_REGEX } from "#internal/constants";
import validateString from "#internal/validate-string";
import dot from "#lib/dot";
import isSep from "#lib/is-sep";
import resolveWith from "#lib/resolve-with";
import toPosix from "#lib/to-posix";
function toNamespacedPath(path, options) {
validateString(path, "path");
if (path) {
path = toPosix(path);
const resolved = resolveWith(path, options);
if (resolved.length > 2) {
if (isSep(resolved[0]) && isSep(resolved[1]) && !["?", dot].includes(resolved[2])) {
return toPosix("\\\\?\\UNC\\") + resolved.slice(2);
}
if (DRIVE_PATH_REGEX.test(resolved) && isSep(resolved[2])) {
return toPosix("\\\\?\\") + resolved;
}
}
return resolved;
}
return path;
}
var to_namespaced_path_default = toNamespacedPath;
export {
to_namespaced_path_default as default
};