|
2 | 2 |
|
3 | 3 | /* globals Blob, Promise, Response */ |
4 | 4 |
|
5 | | -;((exports, unescape, encodeURIComponent, Uint8Array) => { |
| 5 | +;((exports, Uint8Array) => { |
6 | 6 |
|
7 | 7 | // Attach createZip to `window` in non-module context |
8 | 8 | exports.createZip = (files, opts, next) => { |
|
28 | 28 | for (var pos = str.length, arr = new Uint8Array(pos); pos--; arr[pos] = str.charCodeAt(pos)); |
29 | 29 | return arr |
30 | 30 | } |
| 31 | + , toUtf8 = str => unescape(encodeURIComponent(str || "")) |
31 | 32 | , compress = (uint, len, cb) => { |
32 | 33 | if (opts && opts.deflate) { |
33 | 34 | var compressed = opts.deflate(uint) |
|
44 | 45 | k = files[i++] |
45 | 46 | if (!k) { |
46 | 47 | k = files.length |
47 | | - name = unescape(encodeURIComponent(opts && opts.comment || "")) |
| 48 | + name = toUtf8(opts && opts.comment) |
48 | 49 | push(toUint(cd + "PK\5\6" + le32(0) + le32((k<<16) + k) + le32(cd.length) + le32(offset) + le16(name.length) + name)) |
49 | 50 | file = new Uint8Array(outLen) |
50 | 51 | for (i = 0, offset = 0; (j = out[i++]); offset += j.length) file.set(j, offset); |
51 | 52 | return resolve(file) |
52 | 53 | } |
53 | 54 | var fileLen |
54 | | - , name = unescape(encodeURIComponent(k.name)) |
| 55 | + , name = toUtf8(k.name) |
55 | 56 | , nameLen = name.length |
56 | 57 | , file = k.content |
57 | 58 | , crc = -1 |
58 | 59 |
|
59 | | - if (typeof file === "string") file = toUint(unescape(encodeURIComponent(file))) |
| 60 | + if (typeof file === "string") file = toUint(toUtf8(file)) |
60 | 61 | fileLen = file.length |
61 | 62 |
|
62 | 63 | for (j = 0; j < fileLen; ) { |
|
83 | 84 | } |
84 | 85 |
|
85 | 86 | // this is `exports` in module and `window` in browser |
86 | | -})(this, unescape, encodeURIComponent, Uint8Array) // jshint ignore:line |
| 87 | +})(this, Uint8Array) // jshint ignore:line |
87 | 88 |
|
0 commit comments