diff --git a/examples/vite-vue3/src/components/kebab-case/KebabCaseFile.vue b/examples/vite-vue3/src/components/kebab-case/KebabCaseFile.vue
new file mode 100644
index 00000000..80207b0d
--- /dev/null
+++ b/examples/vite-vue3/src/components/kebab-case/KebabCaseFile.vue
@@ -0,0 +1,9 @@
+
+
+
+ KebabCaseFile Component: kebab-case/KebabCaseFile.vue
+
diff --git a/examples/vite-vue3/src/components/kebab-case/kebab-case-collapse/KebabCaseCollapseFile.vue b/examples/vite-vue3/src/components/kebab-case/kebab-case-collapse/KebabCaseCollapseFile.vue
new file mode 100644
index 00000000..60600ab9
--- /dev/null
+++ b/examples/vite-vue3/src/components/kebab-case/kebab-case-collapse/KebabCaseCollapseFile.vue
@@ -0,0 +1,9 @@
+
+
+
+ KebabCaseCollapseFile Component: kebab-case/kebab-case-collapse/KebabCaseCollapseFile.vue
+
diff --git a/src/core/utils.ts b/src/core/utils.ts
index 0881b51d..cc60914d 100644
--- a/src/core/utils.ts
+++ b/src/core/utils.ts
@@ -159,12 +159,13 @@ export function getNameFromFilePath(filePath: string, options: ResolvedOptions):
for (const fileOrFolderName of namespaced) {
let cumulativePrefix = ''
let didCollapse = false
+ const pascalCasedName = pascalCase(fileOrFolderName)
for (const parentFolder of [...collapsed].reverse()) {
- cumulativePrefix = `${capitalize(parentFolder)}${cumulativePrefix}`
+ cumulativePrefix = `${parentFolder}${cumulativePrefix}`
- if (pascalCase(fileOrFolderName).startsWith(pascalCase(cumulativePrefix))) {
- const collapseSamePrefix = fileOrFolderName.slice(cumulativePrefix.length)
+ if (pascalCasedName.startsWith(cumulativePrefix)) {
+ const collapseSamePrefix = pascalCasedName.slice(cumulativePrefix.length)
collapsed.push(collapseSamePrefix)
@@ -174,7 +175,7 @@ export function getNameFromFilePath(filePath: string, options: ResolvedOptions):
}
if (!didCollapse)
- collapsed.push(fileOrFolderName)
+ collapsed.push(pascalCasedName)
}
namespaced = collapsed
diff --git a/test/__snapshots__/search.test.ts.snap b/test/__snapshots__/search.test.ts.snap
index e635cc73..4bb99427 100644
--- a/test/__snapshots__/search.test.ts.snap
+++ b/test/__snapshots__/search.test.ts.snap
@@ -38,6 +38,14 @@ exports[`search > should with namespace & collapse 1`] = `
"as": "ComponentD",
"from": "src/components/ComponentD.vue",
},
+ {
+ "as": "KebabCaseCollapseFile",
+ "from": "src/components/kebab-case/kebab-case-collapse/KebabCaseCollapseFile.vue",
+ },
+ {
+ "as": "KebabCaseFile",
+ "from": "src/components/kebab-case/KebabCaseFile.vue",
+ },
{
"as": "Recursive",
"from": "src/components/Recursive.vue",
@@ -91,6 +99,14 @@ exports[`search > should with namespace 1`] = `
"as": "ComponentD",
"from": "src/components/ComponentD.vue",
},
+ {
+ "as": "KebabCaseKebabCaseCollapseKebabCaseCollapseFile",
+ "from": "src/components/kebab-case/kebab-case-collapse/KebabCaseCollapseFile.vue",
+ },
+ {
+ "as": "KebabCaseKebabCaseFile",
+ "from": "src/components/kebab-case/KebabCaseFile.vue",
+ },
{
"as": "Recursive",
"from": "src/components/Recursive.vue",
@@ -152,6 +168,14 @@ exports[`search > should work 1`] = `
"as": "FolderAndComponentPartially",
"from": "src/components/collapse/collapseFolder/FolderAndComponentPartially.vue",
},
+ {
+ "as": "KebabCaseCollapseFile",
+ "from": "src/components/kebab-case/kebab-case-collapse/KebabCaseCollapseFile.vue",
+ },
+ {
+ "as": "KebabCaseFile",
+ "from": "src/components/kebab-case/KebabCaseFile.vue",
+ },
{
"as": "Recursive",
"from": "src/components/Recursive.vue",