@optique/core 1.0.0-dev.886 → 1.0.0-dev.893

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,16 +5,17 @@ const require_message = require('./message.cjs');
5
5
  * A regular expression pattern for valid program names that can be safely
6
6
  * interpolated into shell scripts.
7
7
  *
8
- * This pattern allows:
8
+ * The first character must be alphanumeric or underscore. Subsequent
9
+ * characters may also include hyphens and dots:
9
10
  * - Letters (a-z, A-Z)
10
11
  * - Numbers (0-9)
11
12
  * - Underscore (_)
12
- * - Hyphen (-)
13
- * - Dot (.)
13
+ * - Hyphen (-) — not as the first character
14
+ * - Dot (.) — not as the first character
14
15
  *
15
16
  * @internal
16
17
  */
17
- const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]+$/;
18
+ const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/;
18
19
  /**
19
20
  * Validates a program name for safe use in shell scripts.
20
21
  *
@@ -27,7 +28,7 @@ const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]+$/;
27
28
  * @internal
28
29
  */
29
30
  function validateProgramName(programName) {
30
- if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must contain only alphanumeric characters, underscores, hyphens, and dots.`);
31
+ if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must start with an alphanumeric character or underscore, and contain only alphanumeric characters, underscores, hyphens, and dots.`);
31
32
  }
32
33
  /**
33
34
  * The Bash shell completion generator.
@@ -5,16 +5,17 @@ import { formatMessage } from "./message.js";
5
5
  * A regular expression pattern for valid program names that can be safely
6
6
  * interpolated into shell scripts.
7
7
  *
8
- * This pattern allows:
8
+ * The first character must be alphanumeric or underscore. Subsequent
9
+ * characters may also include hyphens and dots:
9
10
  * - Letters (a-z, A-Z)
10
11
  * - Numbers (0-9)
11
12
  * - Underscore (_)
12
- * - Hyphen (-)
13
- * - Dot (.)
13
+ * - Hyphen (-) — not as the first character
14
+ * - Dot (.) — not as the first character
14
15
  *
15
16
  * @internal
16
17
  */
17
- const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]+$/;
18
+ const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/;
18
19
  /**
19
20
  * Validates a program name for safe use in shell scripts.
20
21
  *
@@ -27,7 +28,7 @@ const SAFE_PROGRAM_NAME_PATTERN = /^[a-zA-Z0-9_.-]+$/;
27
28
  * @internal
28
29
  */
29
30
  function validateProgramName(programName) {
30
- if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must contain only alphanumeric characters, underscores, hyphens, and dots.`);
31
+ if (!SAFE_PROGRAM_NAME_PATTERN.test(programName)) throw new Error(`Invalid program name for shell completion: "${programName}". Program names must start with an alphanumeric character or underscore, and contain only alphanumeric characters, underscores, hyphens, and dots.`);
31
32
  }
32
33
  /**
33
34
  * The Bash shell completion generator.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.886+4b42a9bd",
3
+ "version": "1.0.0-dev.893+52c8345b",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",