windmill-utils-internal 1.3.6 → 1.3.7

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.
@@ -29,10 +29,6 @@ export declare const EXTENSION_TO_LANGUAGE: Record<string, SupportedLanguage>;
29
29
  * @returns The language, or undefined if not recognized
30
30
  */
31
31
  export declare function getLanguageFromExtension(ext: string, defaultTs?: "bun" | "deno"): SupportedLanguage | undefined;
32
- /**
33
- * Sanitizes a summary string for use as a filesystem-safe name.
34
- * Removes or replaces characters that are invalid on common filesystems.
35
- */
36
32
  export declare function sanitizeForFilesystem(summary: string): string;
37
33
  export interface PathAssigner {
38
34
  assignPath(summary: string | undefined, language: SupportedLanguage): [string, string];
@@ -105,16 +105,21 @@ function getLanguageFromExtension(ext, defaultTs = "bun") {
105
105
  * Sanitizes a summary string for use as a filesystem-safe name.
106
106
  * Removes or replaces characters that are invalid on common filesystems.
107
107
  */
108
+ const WINDOWS_RESERVED = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/;
108
109
  function sanitizeForFilesystem(summary) {
109
- return summary
110
+ const name = summary
110
111
  .toLowerCase()
111
112
  .replaceAll(" ", "_")
112
113
  // Remove characters invalid on Windows/Unix/Mac: / \ : * ? " < > |
113
114
  // Also remove control characters (0x00-0x1F) and DEL (0x7F)
114
115
  // deno-lint-ignore no-control-regex
115
116
  .replace(/[/\\:*?"<>|\x00-\x1f\x7f]/g, "")
117
+ // Collapse consecutive underscores
118
+ .replace(/_+/g, "_")
116
119
  // Trim leading/trailing dots and underscores (hidden files, Windows edge cases)
117
120
  .replace(/^[._]+|[._]+$/g, "");
121
+ // Prefix Windows reserved device names (CON, PRN, AUX, NUL, COM0-9, LPT0-9)
122
+ return WINDOWS_RESERVED.test(name) ? `_${name}` : name;
118
123
  }
119
124
  /**
120
125
  * Creates a new path assigner for inline scripts.
@@ -29,10 +29,6 @@ export declare const EXTENSION_TO_LANGUAGE: Record<string, SupportedLanguage>;
29
29
  * @returns The language, or undefined if not recognized
30
30
  */
31
31
  export declare function getLanguageFromExtension(ext: string, defaultTs?: "bun" | "deno"): SupportedLanguage | undefined;
32
- /**
33
- * Sanitizes a summary string for use as a filesystem-safe name.
34
- * Removes or replaces characters that are invalid on common filesystems.
35
- */
36
32
  export declare function sanitizeForFilesystem(summary: string): string;
37
33
  export interface PathAssigner {
38
34
  assignPath(summary: string | undefined, language: SupportedLanguage): [string, string];
@@ -97,16 +97,21 @@ export function getLanguageFromExtension(ext, defaultTs = "bun") {
97
97
  * Sanitizes a summary string for use as a filesystem-safe name.
98
98
  * Removes or replaces characters that are invalid on common filesystems.
99
99
  */
100
+ const WINDOWS_RESERVED = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/;
100
101
  export function sanitizeForFilesystem(summary) {
101
- return summary
102
+ const name = summary
102
103
  .toLowerCase()
103
104
  .replaceAll(" ", "_")
104
105
  // Remove characters invalid on Windows/Unix/Mac: / \ : * ? " < > |
105
106
  // Also remove control characters (0x00-0x1F) and DEL (0x7F)
106
107
  // deno-lint-ignore no-control-regex
107
108
  .replace(/[/\\:*?"<>|\x00-\x1f\x7f]/g, "")
109
+ // Collapse consecutive underscores
110
+ .replace(/_+/g, "_")
108
111
  // Trim leading/trailing dots and underscores (hidden files, Windows edge cases)
109
112
  .replace(/^[._]+|[._]+$/g, "");
113
+ // Prefix Windows reserved device names (CON, PRN, AUX, NUL, COM0-9, LPT0-9)
114
+ return WINDOWS_RESERVED.test(name) ? `_${name}` : name;
110
115
  }
111
116
  /**
112
117
  * Creates a new path assigner for inline scripts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-utils-internal",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Internal utility functions for Windmill",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",