windmill-utils-internal 1.3.5 → 1.3.6

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,6 +29,11 @@ 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
+ export declare function sanitizeForFilesystem(summary: string): string;
32
37
  export interface PathAssigner {
33
38
  assignPath(summary: string | undefined, language: SupportedLanguage): [string, string];
34
39
  }
@@ -93,6 +93,21 @@ export function getLanguageFromExtension(ext, defaultTs = "bun") {
93
93
  }
94
94
  return undefined;
95
95
  }
96
+ /**
97
+ * Sanitizes a summary string for use as a filesystem-safe name.
98
+ * Removes or replaces characters that are invalid on common filesystems.
99
+ */
100
+ export function sanitizeForFilesystem(summary) {
101
+ return summary
102
+ .toLowerCase()
103
+ .replaceAll(" ", "_")
104
+ // Remove characters invalid on Windows/Unix/Mac: / \ : * ? " < > |
105
+ // Also remove control characters (0x00-0x1F) and DEL (0x7F)
106
+ // deno-lint-ignore no-control-regex
107
+ .replace(/[/\\:*?"<>|\x00-\x1f\x7f]/g, "")
108
+ // Trim leading/trailing dots and underscores (hidden files, Windows edge cases)
109
+ .replace(/^[._]+|[._]+$/g, "");
110
+ }
96
111
  /**
97
112
  * Creates a new path assigner for inline scripts.
98
113
  *
@@ -110,7 +125,7 @@ export function newPathAssigner(defaultTs, options) {
110
125
  const seen_names = new Set();
111
126
  function assignPath(summary, language) {
112
127
  let name;
113
- name = summary?.toLowerCase()?.replaceAll(" ", "_") ?? "";
128
+ name = summary ? sanitizeForFilesystem(summary) : "";
114
129
  let original_name = name;
115
130
  if (name == "") {
116
131
  original_name = INLINE_SCRIPT_PREFIX;
@@ -141,7 +156,7 @@ export function newRawAppPathAssigner(defaultTs) {
141
156
  const seen_names = new Set();
142
157
  function assignPath(summary, language) {
143
158
  let name;
144
- name = summary?.toLowerCase()?.replaceAll(" ", "_") ?? "";
159
+ name = summary ? sanitizeForFilesystem(summary) : "";
145
160
  let original_name = name;
146
161
  if (name == "") {
147
162
  original_name = "runnable";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-utils-internal",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Internal utility functions for Windmill",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",