UNPKG

337 BJavaScriptView Raw
1const { sep, normalize } = require("path");
2
3function cleanPath(dirPath) {
4 let normalized = normalize(dirPath);
5
6 // to account for / path
7 if (normalized.length > 1 && normalized[normalized.length - 1] === sep)
8 normalized = normalized.substring(0, normalized.length - 1);
9 return normalized;
10}
11
12module.exports = { cleanPath };