Skip to content

Commit

Permalink
allow "./" in get entry
Browse files Browse the repository at this point in the history
  • Loading branch information
5saviahv committed Jun 24, 2024
1 parent a2a87a7 commit 3c7f4a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion adm-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = function (/**String*/ input, /** object */ options) {
if (entry && _zip) {
var item;
// If entry was given as a file name
if (typeof entry === "string") item = _zip.getEntry(entry);
if (typeof entry === "string") item = _zip.getEntry(pth.posix.normalize(entry));
// if entry was given as a ZipEntry object
if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);

Expand Down
10 changes: 5 additions & 5 deletions test/mbcs/mbcs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe("Multibyte Character Sets in Filename", () => {
const zip2 = new Zip(pth.join(destination, "06-jp_name.zip"));
const text1 = zip2.readAsText(file);
assert(text1 === content, text1);
const entry2 = zip2.getEntry("test/" + file);
const entry2 = zip2.getEntry("./test/" + file);
const text2 = zip2.readAsText(entry2);
assert(text2 === content, text2);
assert(entry2.header.flags_efs);
Expand All @@ -192,7 +192,7 @@ describe("Multibyte Character Sets in Filename", () => {
let entry1 = zip2.getEntry(file);
let bufdata1 = zip2.readFile(entry1);
assert(bufdata1.equals(content));
let entry2 = zip2.getEntry("test/" + file);
let entry2 = zip2.getEntry("./test/" + file);
let bufdata2 = zip2.readFile(entry2);
assert(bufdata2.equals(content));
assert(entry1.header.flags_efs === false);
Expand Down Expand Up @@ -237,7 +237,7 @@ describe("Multibyte Character Sets in Filename", () => {
const zip2 = new Zip(pth.join(destination, "09-heb_name.zip"));
const text1 = zip2.readAsText(file);
assert(text1 === content, text1);
const entry2 = zip2.getEntry("test/" + file);
const entry2 = zip2.getEntry("./test/" + file);
const text2 = zip2.readAsText(entry2);
assert(text2 === content, text2);
assert(entry2.header.flags_efs);
Expand Down Expand Up @@ -289,7 +289,7 @@ describe("Multibyte Character Sets in Filename", () => {
let entry1 = zip2.getEntry(file);
let text1 = zip2.readAsText(entry1, "utf16le");
assert(text1 === content, text1);
let entry2 = zip2.getEntry("test/" + file);
let entry2 = zip2.getEntry("./test/" + file);
let text2 = zip2.readAsText(entry2, "utf16le");
assert(text2 === content, text2);
assert(entry1.header.flags_efs === false);
Expand All @@ -312,7 +312,7 @@ describe("Multibyte Character Sets in Filename", () => {
let entry1 = zip2.getEntry(file);
let text1 = zip2.readAsText(entry1, "utf16le");
assert(text1 === content, text1);
let entry2 = zip2.getEntry("test/" + file);
let entry2 = zip2.getEntry("./test/" + file);
let text2 = zip2.readAsText(entry2, "utf16le");
assert(text2 === content, text2);
assert(entry1.header.flags_efs);
Expand Down

0 comments on commit 3c7f4a9

Please sign in to comment.