@spfn/core 0.1.0-alpha.27 → 0.1.0-alpha.29

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.
@@ -194,13 +194,30 @@ function extractResourceName(path) {
194
194
  if (staticSegments.length === 0) {
195
195
  return "root";
196
196
  }
197
+ const first = toCamelCase(staticSegments[0], false);
197
198
  if (staticSegments.length === 1) {
198
- return staticSegments[0];
199
+ return first;
199
200
  }
200
- const result = [staticSegments[0]];
201
+ const result = [first];
201
202
  for (let i = 1; i < staticSegments.length; i++) {
202
203
  const seg = staticSegments[i];
203
- result.push(seg.charAt(0).toUpperCase() + seg.slice(1));
204
+ result.push(toCamelCase(seg, true));
205
+ }
206
+ return result.join("");
207
+ }
208
+ function toCamelCase(str, capitalize) {
209
+ const parts = str.split(/[-_]/);
210
+ if (parts.length === 1) {
211
+ return capitalize ? str.charAt(0).toUpperCase() + str.slice(1) : str;
212
+ }
213
+ const result = [];
214
+ for (let i = 0; i < parts.length; i++) {
215
+ const part = parts[i];
216
+ if (i === 0 && !capitalize) {
217
+ result.push(part);
218
+ } else {
219
+ result.push(part.charAt(0).toUpperCase() + part.slice(1));
220
+ }
204
221
  }
205
222
  return result.join("");
206
223
  }