From 233f829bfa9577b07c43544b4d5f574d21991743 Mon Sep 17 00:00:00 2001 From: skoniks Date: Wed, 5 Jun 2024 20:41:05 +0300 Subject: [PATCH] Fix utils canonical to valid posix --- test/utils.test.js | 8 ++++---- util/utils.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/utils.test.js b/test/utils.test.js index 5a60238..5944d5b 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -79,10 +79,10 @@ describe("utils - sanitizing functions :", () => { { file: "./../file", result: "file" }, { file: "../../file", result: "file" }, { file: "../../file1/../file2", result: "file2" }, - { file: "../subfolder/file2", result: `subfolder${pth.sep}file2` }, - { file: "../subfolder2/file2", result: `subfolder2${pth.sep}file2` }, - { file: "../subfolder/file2", result: `subfolder${pth.sep}file2` }, - { file: "../../subfolder2/file2", result: `subfolder2${pth.sep}file2` } + { file: "../subfolder/file2", result: "subfolder/file2" }, + { file: "../subfolder2/file2", result: "subfolder2/file2" }, + { file: "../subfolder/file2", result: "subfolder/file2" }, + { file: "../../subfolder2/file2", result: "subfolder2/file2" } ]; for (let test of tests) { diff --git a/util/utils.js b/util/utils.js index 9d732ba..7758419 100644 --- a/util/utils.js +++ b/util/utils.js @@ -208,7 +208,7 @@ Utils.canonical = function (/*string*/ path) { if (!path) return ""; // trick normalize think path is absolute var safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/")); - return pth.join(".", safeSuffix); + return pth.posix.join(".", safeSuffix); }; // make abolute paths taking prefix as root folder