patch path normalization

This commit is contained in:
timothycarambat 2024-05-22 11:50:01 -05:00
parent e2439c6d4c
commit e208074ef4

View file

@ -122,7 +122,7 @@ function isWithin(outer, inner) {
function normalizePath(filepath = "") {
const result = path
.normalize(filepath.trim())
.normalize(filepath.replace(/\s/g, "-").trim())
.replace(/^(\.\.(\/|\\|$))+/, "")
.trim();
if (["..", ".", "/"].includes(result)) throw new Error("Invalid path.");