Fix normalizeQuery regex to preserve leading dots in dotfile names
The regex /^[@./]+/ greedily stripped all leading @, ., and / characters, which caused dotfile queries like '.env' to be normalized to 'env'. This made searches match too broadly and rank actual dotfiles last. Changed to /^@?(\.\/)?/ which only strips an optional @ prefix and an optional ./ path prefix, preserving leading dots that are meaningful parts of filenames.
This commit is contained in:
1 parent
798993550b
commit
2e5933cec6
1 file changed
+1
-1
@@ -54,7 +54,7 @@ function basenameOf(input: string): string {
|
||||
}
|
||||
|
||||
function normalizeQuery(input: string): string {
|
||||
return input.trim().replace(/^[@./]+/, "").toLowerCase();
|
||||
return input.trim().replace(/^@?(\.\/)?/, "").toLowerCase();
|
||||
}
|
||||
|
||||
function scoreEntry(entry: ProjectEntry, query: string): number {
|
||||
|
||||
Reference in new issue
Block a user