Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing error when type is undefined in ZipObject.async #479

Closed
Darker opened this issue Nov 7, 2017 · 1 comment
Closed

Confusing error when type is undefined in ZipObject.async #479

Darker opened this issue Nov 7, 2017 · 1 comment

Comments

@Darker
Copy link

Darker commented Nov 7, 2017

I forgot to add type parameter to ZipObject.async:

    settings = JSON.parse(await zip.file(SETTINGS_DEFAULT_PATH).async());

The error:

 TypeError: Cannot read property 'toLowerCase' of undefined
    at ZipObject.internalStream (D:\techsys\webapp\WebDozor\jszip.js:4096:30)
    at ZipObject.async (D:\techsys\webapp\WebDozor\jszip.js:4122:21)
    at __dirname (D:\techsys\webapp\WebDozor\make_package.js:46:73)

The line:

    internalStream: function (type) {
        var outputType = type.toLowerCase();
        var askUnicodeString = outputType === "string" || outputType === "text";
        if (outputType === "binarystring" || outputType === "text") {
            outputType = "string";
        }

Some input check would solve this issue. Such as if(typeof type!="string") throw new Error("Type must be string value.");

@dduponchel
Copy link
Collaborator

The method generateAsync() has this check (almost, the type isn't checked). I'll copy this check to async().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants