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: allow dots in desktop app names

Tw93df62f1877228
diff --git a/bin/options/index.ts b/bin/options/index.ts
index 63945874..bcb6a0aa 100644
--- a/bin/options/index.ts
+++ b/bin/options/index.ts
@@ -18,7 +18,7 @@ function resolveAppName(name: string, platform: NodeJS.Platform): string {
return platform !== 'linux' ? capitalizeFirstLetter(domain) : domain;
}
-function resolveLocalAppName(
+export function resolveLocalAppName(
filePath: string,
platform: NodeJS.Platform,
): string {
@@ -27,18 +27,18 @@ function resolveLocalAppName(
return generateLinuxPackageName(baseName) || 'pake-app';
}
const normalized = baseName
- .replace(/[^a-zA-Z0-9\u4e00-\u9fff -]/g, '')
- .replace(/^[ -]+/, '')
+ .replace(/[^a-zA-Z0-9\u4e00-\u9fff .-]/g, '')
+ .replace(/^[ .-]+/, '')
.replace(/\s+/g, ' ')
.trim();
return normalized || 'pake-app';
}
-function isValidName(name: string, platform: NodeJS.Platform): boolean {
+export function isValidName(name: string, platform: NodeJS.Platform): boolean {
const reg =
platform === 'linux'
? /^[a-z0-9\u4e00-\u9fff][a-z0-9\u4e00-\u9fff-]*$/
- : /^[a-zA-Z0-9\u4e00-\u9fff][a-zA-Z0-9\u4e00-\u9fff- ]*$/;
+ : /^[a-zA-Z0-9\u4e00-\u9fff][a-zA-Z0-9\u4e00-\u9fff .-]*$/;
return !!name && reg.test(name);
}
@@ -66,7 +66,7 @@ export default async function handleOptions(
if (name && !isValidName(name, platform)) {
const LINUX_NAME_ERROR = `✕ Name should only include lowercase letters, numbers, and dashes (not leading dashes). Examples: com-123-xxx, 123pan, pan123, weread, we-read, 123.`;
- const DEFAULT_NAME_ERROR = `✕ Name should only include letters, numbers, dashes, and spaces (not leading dashes and spaces). Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read, 123.`;
+ const DEFAULT_NAME_ERROR = `✕ Name should only include letters, numbers, dots, dashes, and spaces (not leading dots, dashes, and spaces). Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read, Vectorizer.AI, 123.`;
const errorMsg =
platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR;
if (isActions) {
diff --git a/dist/cli.js b/dist/cli.js
index 306d7e05..d0e9d81c 100644
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -2321,8 +2321,8 @@ function resolveLocalAppName(filePath, platform) {
return generateLinuxPackageName(baseName) || 'pake-app';
}
const normalized = baseName
- .replace(/[^a-zA-Z0-9\u4e00-\u9fff -]/g, '')
- .replace(/^[ -]+/, '')
+ .replace(/[^a-zA-Z0-9\u4e00-\u9fff .-]/g, '')
+ .replace(/^[ .-]+/, '')
.replace(/\s+/g, ' ')
.trim();
return normalized || 'pake-app';
@@ -2330,7 +2330,7 @@ function resolveLocalAppName(filePath, platform) {
function isValidName(name, platform) {
const reg = platform === 'linux'
? /^[a-z0-9\u4e00-\u9fff][a-z0-9\u4e00-\u9fff-]*$/
- : /^[a-zA-Z0-9\u4e00-\u9fff][a-zA-Z0-9\u4e00-\u9fff- ]*$/;
+ : /^[a-zA-Z0-9\u4e00-\u9fff][a-zA-Z0-9\u4e00-\u9fff .-]*$/;
return !!name && reg.test(name);
}
async function handleOptions(options, url) {
@@ -2351,7 +2351,7 @@ async function handleOptions(options, url) {
}
if (name && !isValidName(name, platform)) {
const LINUX_NAME_ERROR = `✕ Name should only include lowercase letters, numbers, and dashes (not leading dashes). Examples: com-123-xxx, 123pan, pan123, weread, we-read, 123.`;
- const DEFAULT_NAME_ERROR = `✕ Name should only include letters, numbers, dashes, and spaces (not leading dashes and spaces). Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read, 123.`;
+ const DEFAULT_NAME_ERROR = `✕ Name should only include letters, numbers, dots, dashes, and spaces (not leading dots, dashes, and spaces). Examples: 123pan, 123Pan, Pan123, weread, WeRead, WERead, we-read, We Read, Vectorizer.AI, 123.`;
const errorMsg = platform === 'linux' ? LINUX_NAME_ERROR : DEFAULT_NAME_ERROR;
if (isActions) {
logger.error(errorMsg);
diff --git a/tests/unit/options-name.test.ts b/tests/unit/options-name.test.ts
new file mode 100644
index 00000000..e6792e71
--- /dev/null
+++ b/tests/unit/options-name.test.ts
@@ -0,0 +1,41 @@
+import { describe, expect, it } from 'vitest';
+import { isValidName, resolveLocalAppName } from '@/options/index';
+
+describe('option name validation', () => {
+ it('allows dots inside macOS and Windows app names', () => {
+ expect(isValidName('Vectorizer.AI', 'darwin')).toBe(true);
+ expect(isValidName('Vectorizer.AI', 'win32')).toBe(true);
+ });
+
+ it('rejects leading dots, dashes, and spaces on macOS and Windows', () => {
+ expect(isValidName('.hidden', 'darwin')).toBe(false);
+ expect(isValidName('-hidden', 'win32')).toBe(false);
+ expect(isValidName(' Hidden', 'darwin')).toBe(false);
+ });
+
+ it('keeps Linux package names stricter than desktop app names', () => {
+ expect(isValidName('vectorizer.ai', 'linux')).toBe(false);
+ expect(isValidName('vectorizer-ai', 'linux')).toBe(true);
+ });
+});
+
+describe('local app name resolution', () => {
+ it('preserves dots in local file names on macOS and Windows', () => {
+ expect(resolveLocalAppName('/tmp/Vectorizer.AI.html', 'darwin')).toBe(
+ 'Vectorizer.AI',
+ );
+ expect(resolveLocalAppName('/tmp/Vectorizer.AI.html', 'win32')).toBe(
+ 'Vectorizer.AI',
+ );
+ });
+
+ it('normalizes leading dots from local file names', () => {
+ expect(resolveLocalAppName('/tmp/.hidden.html', 'darwin')).toBe('hidden');
+ });
+
+ it('normalizes dotted local names for Linux package names', () => {
+ expect(resolveLocalAppName('/tmp/Vectorizer.AI.html', 'linux')).toBe(
+ 'vectorizer-ai',
+ );
+ });
+});