Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

Merge branch 'main' into ghraven/strict-zoom-parser

Tw931b02d7ce523e
diff --cc dist/cli.js
index 306d7e05,1a3d8c33..4f3d7d43
--- a/dist/cli.js
+++ b/dist/cli.js
@@@ -68,7 -68,7 +68,7 @@@ var scripts =
};
var type = "module";
var exports$1 = "./dist/cli.js";
--var license = "MIT";
++var license = "GPL-3.0-or-later";
var dependencies = {
"@tauri-apps/api": "~2.10.1",
"@tauri-apps/cli": "^2.10.0",
@@@ -2565,8 -2565,8 +2565,8 @@@ ${green('|_| \\__,_|_|\\_\\___| can
.addOption(new Option('--zoom <number>', 'Initial page zoom level (50-200)')
.default(DEFAULT_PAKE_OPTIONS.zoom)
.argParser((value) => {
-- const zoom = parseInt(value);
-- if (isNaN(zoom) || zoom < 50 || zoom > 200) {
++ const zoom = Number(value);
++ if (!Number.isFinite(zoom) || zoom < 50 || zoom > 200) {
throw new Error('--zoom must be a number between 50 and 200');
}
return zoom;
diff --cc tests/unit/cli-options.test.ts
index 0f588dd8,8f45ac97..b5fab702
--- a/tests/unit/cli-options.test.ts
+++ b/tests/unit/cli-options.test.ts
@@@ -47,13 -48,9 +48,19 @@@ describe('CLI options', () =>
expect(option?.hidden).toBe(true);
});
+ it('rejects malformed zoom values instead of truncating them', () => {
+ const option = program.options.find((item) => item.long === '--zoom');
+
+ expect(option).toBeDefined();
+ expect(option?.parseArg?.('80', undefined)).toBe(80);
+ expect(() => option?.parseArg?.('80abc', undefined)).toThrow(
+ '--zoom must be a number between 50 and 200',
+ );
+ });
++
+ it('rejects non-finite numeric option values', () => {
+ expect(() => validateNumberInput('Infinity')).toThrow('Not a number.');
+ expect(() => validateNumberInput('-Infinity')).toThrow('Not a number.');
+ expect(validateNumberInput('1200')).toBe(1200);
+ });
});