Repository: cthackers/adm-zip (2025-06-24T09:06:27Z)

Issue:
addLocalFolderPromise is broken when providing absolute path on mac
caused by this change. fixPath is calling path.join which will join two absolute paths.

https://github.com/cthackers/adm-zip/blame/b148463f5f9f67427df6dd19798cdce20bde3d74/adm-zip.js#L488


Discussion:
Also have this issue. Resulting zip is empty
same here
It's also happening on linux
also have this issue



Patch:
diff --git a/adm-zip.js b/adm-zip.js
index 31dddf2..4bac5c8 100644
--- a/adm-zip.js
+++ b/adm-zip.js
@@ -86,7 +86,7 @@ module.exports = function (/**String*/ input, /** object */ options) {
     function fixPath(zipPath) {
         const { join, normalize, sep } = pth.posix;
         // convert windows file separators and normalize
-        return join(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
+        return join(pth.isAbsolute(zipPath) ? "/": '.',  normalize(sep + zipPath.split("\\").join(sep) + sep));
     }
 
     function filenameFilter(filterfn) {


Test patch:
diff --git a/test/methods/methods.test.js b/test/methods/methods.test.js
index 4cf8777..8d61807 100644
--- a/test/methods/methods.test.js
+++ b/test/methods/methods.test.js
@@ -638,6 +638,26 @@ describe("adm-zip.js - methods handling local files", () => {
 
             expect(zip1Entries.sort()).to.deep.equal(expected.sort());
         });
+
+
+
+        it("zip.addLocalFolderPromise(destination, {zipPath}) with absolute path", async function () {
+            const zip = new Zip();
+            await zip.addLocalFolderPromise(pth.resolve(destination), { zipPath: "parent" });
+            const zip1Entries = zip.getEntries().map((e) => e.entryName);
+
+            const expected = [
+                "parent/subfolder1/",
+                "parent/subfolder1/subfolder2/",
+                "parent/subfolder1/subfolder2/subfolder3/",
+                "parent/subfolder1/subfolder2/zipEntry1.txt",
+                "parent/subfolder1/subfolder2/subfolder3/subfolder4/",
+                "parent/subfolder1/subfolder2/subfolder3/zipEntry2.txt",
+                "parent/subfolder1/subfolder2/subfolder3/zipEntry3.txt"
+            ];
+
+            expect(zip1Entries.sort()).to.deep.equal(expected.sort());
+        });
     });
 });