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.

fix: reject fractional --zoom values that break Rust u32 deserialization

Luís Miguel7edf2af428b0
diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.ts
index 35024f69..f6ae7f89 100644
--- a/bin/helpers/cli-program.ts
+++ b/bin/helpers/cli-program.ts
@@ -227,8 +227,8 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
.default(DEFAULT.zoom)
.argParser((value) => {
const zoom = Number(value);
- if (!Number.isFinite(zoom) || zoom < 50 || zoom > 200) {
- throw new Error('--zoom must be a number between 50 and 200');
+ if (!Number.isInteger(zoom) || zoom < 50 || zoom > 200) {
+ throw new Error('--zoom must be an integer between 50 and 200');
}
return zoom;
})
diff --git a/dist/cli.js b/dist/cli.js
index 1387ed56..3d2d4297 100644
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -2915,8 +2915,8 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
.default(DEFAULT_PAKE_OPTIONS.zoom)
.argParser((value) => {
const zoom = Number(value);
- if (!Number.isFinite(zoom) || zoom < 50 || zoom > 200) {
- throw new Error('--zoom must be a number between 50 and 200');
+ if (!Number.isInteger(zoom) || zoom < 50 || zoom > 200) {
+ throw new Error('--zoom must be an integer between 50 and 200');
}
return zoom;
})
diff --git a/docs/cli-usage.md b/docs/cli-usage.md
index 62c1799f..e5489d29 100644
--- a/docs/cli-usage.md
+++ b/docs/cli-usage.md
@@ -158,7 +158,7 @@ Set the minimum height that the window can be resized to. Prevents UI breakage c
#### [zoom]
-Set initial page zoom level (50-200). Default is `100`. Users can still adjust with `Cmd/Ctrl +/-/0` shortcuts.
+Set initial page zoom level as an integer between 50 and 200. Default is `100`. Users can still adjust with `Cmd/Ctrl +/-/0` shortcuts.
```shell
--zoom <number>
diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.md
index ecd6eb93..d855bc03 100644
--- a/docs/cli-usage_CN.md
+++ b/docs/cli-usage_CN.md
@@ -158,7 +158,7 @@ pake https://github.com --name GitHub
#### [zoom]
-设置初始页面缩放级别(50-200),默认为 `100`。用户仍可通过快捷键(`Cmd/Ctrl +/-/0`)调整。
+设置初始页面缩放级别,取值为 50 到 200 之间的整数,默认为 `100`。用户仍可通过快捷键(`Cmd/Ctrl +/-/0`)调整。
```shell
--zoom <number>
diff --git a/tests/unit/cli-options.test.ts b/tests/unit/cli-options.test.ts
index 0b8a3376..1f0568f9 100644
--- a/tests/unit/cli-options.test.ts
+++ b/tests/unit/cli-options.test.ts
@@ -98,7 +98,12 @@ describe('CLI options', () => {
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',
+ '--zoom must be an integer between 50 and 200',
+ );
+ // Fractional in-range values cannot deserialize into the Rust u32 zoom
+ // field, so they must be rejected rather than forwarded to pake.json.
+ expect(() => option?.parseArg?.('99.5', undefined)).toThrow(
+ '--zoom must be an integer between 50 and 200',
);
});