Skip to content

Commit 0c040e7

Browse files
committed
Fix
1 parent f0c4a44 commit 0c040e7

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

bin/format.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function toFile(isDir, extn, files, dirs, useCRC32, startsWithDot)
5555
? undefined
5656
: concat(data(B64toUI8A(extn)));
5757

58-
const noPath = files.length == 1;
58+
const noPath = !isDir && files.length == 1;
5959
const output = [];
6060
const files8 = [];
6161
let need = 1;
@@ -199,7 +199,7 @@ export async function fromFile(uint8) {
199199

200200
if (content == 0) dirs.push(path);
201201
else files.push([
202-
path == 0 ? name__ : path, content
202+
path == 0 ? '' : path, content
203203
]);
204204

205205
if (i == uint8.length) break;

bin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ function findEmptyDirs(dir) {
464464
fullPath = path.resolve(path.dirname(current), delta);
465465
}
466466
if (!isDir) {
467-
fullPath += (startsWithDot ? '.' : '') + await decompressFromBase64(extn);
467+
fullPath = output[0] + (startsWithDot ? '.' : '') + decompressFromBase64(extn);
468468
}
469469
current = checkPath(fullPath);
470470

bin/windows/ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
88
const uiDir = path.resolve(__dirname, "./ui");
99
const confirmPs1 = path.resolve(uiDir, "./confirm.ps1");
1010
const welcomePs1 = path.resolve(uiDir, "./welcome.ps1");
11-
const compresPs1 = path.resolve(uiDir, "./compress.ps1");
11+
const compresPs1 = path.resolve(__dirname, "./windows/ui/compress.ps1");
1212

1313
export function confirm(title, text, repo, site) {
1414
try {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strc",
3-
"version": "2.1.1-a",
3+
"version": "2.1.1-b",
44
"description": "JavaScript String Compressor - lossless string compression algorithm",
55
"main": "dist/jssc.cjs",
66
"repository": {

src/core.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export async function compress(input, options) {
382382
if (opts.justc && opts.jsonstring) {
383383
const JUSTCobj = await toJUSTC(obj);
384384
const JSONstr = JSON.stringify(await parseJUSTC(JUSTCobj));
385-
if (JSONstr == JSON.stringify(str)) JUSTCstr = JUSTCobj;
385+
if (JSONstr == JSON.stringify(obj)) JUSTCstr = JUSTCobj;
386386
}
387387

388388
if (typeof JUSTCstr != 'undefined' && JUSTCstr.length < str.length && str == JSON.stringify(obj)) {
@@ -899,22 +899,24 @@ export async function decompressFromUint8Array(uint8array, ...params) {
899899

900900
export async function compressLarge(input, ...params) {
901901
const LENGTH = 1024;
902+
if (input.length < LENGTH || typeof input != 'string') return await compress(input, ...params);
903+
902904
const result = [charCode(cryptCharCode(11, false, false, false, undefined, undefined, false, 3))];
903905

904906
for (let i = 0; i < input.length; i += LENGTH) {
905907
const chunk = input.slice(i, i + LENGTH);
906-
const compressed = await compress(chunk, ...params);
908+
const compressed = noDebugMode(await compress(chunk, ...params));
907909
result.push(String.fromCharCode(compressed.length), compressed);
908910
}
909911

910912
return result.join('');
911913
}
912914
export async function compressLargeToBase64(...input) {
913-
const compressed = noDebugMode(await compress(...input));
915+
const compressed = await compressLarge(...input);
914916
return B64Padding(encode(compressed));
915917
}
916918
export async function compressLargeToBase64URL(...input) {
917-
const compressed = noDebugMode(await compress(...input));
919+
const compressed = await compressLarge(...input);
918920
return encode(compressed, 64, B64URL);
919921
}
920922
export async function compressLargeToUint8Array(...input) {

0 commit comments

Comments
 (0)