@kubb/ast 5.0.0-alpha.49 → 5.0.0-alpha.50

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.
package/dist/index.cjs CHANGED
@@ -157,10 +157,16 @@ function toCamelOrPascal(text, pascal) {
157
157
  *
158
158
  * Only splits on dots followed by a letter so that version numbers
159
159
  * embedded in operationIds (e.g. `v2025.0`) are kept intact.
160
+ *
161
+ * Empty segments are filtered before joining. They arise when the text starts with
162
+ * a dot followed immediately by a letter (e.g. `..Schema` splits into `['..', 'Schema']`
163
+ * and `'..'` transforms to an empty string). Without this filter the join would produce
164
+ * a leading `/`, which `path.resolve` would interpret as an absolute path, allowing
165
+ * generated files to escape the configured output directory.
160
166
  */
161
167
  function applyToFileParts(text, transformPart) {
162
168
  const parts = text.split(/\.(?=[a-zA-Z])/);
163
- return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
169
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).filter(Boolean).join("/");
164
170
  }
165
171
  /**
166
172
  * Converts `text` to camelCase.