Skip to content

Commit 3441ab7

Browse files
case insensitive language filter
1 parent d35ab77 commit 3441ab7

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Changed
1616
- Added commit graph generation to improve performance for commit traversal operations. [#791](https://github.com/sourcebot-dev/sourcebot/pull/791)
17+
- Made the code search `lang:` filter case insensitive. [#795](https://github.com/sourcebot-dev/sourcebot/pull/795)
1718

1819
## [4.10.17] - 2026-01-23
1920

packages/web/src/features/search/parser.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { SINGLE_TENANT_ORG_ID } from '@/lib/constants';
2828
import { ServiceErrorException } from '@/lib/serviceError';
2929
import { StatusCodes } from 'http-status-codes';
3030
import { ErrorCode } from '@/lib/errorCodes';
31+
import { languageMetadataMap } from '@/lib/languageMetadata';
3132

3233
// Configure the parser to throw errors when encountering invalid syntax.
3334
const parser = _parser.configure({
@@ -50,6 +51,19 @@ const isForkValue = (value: string): value is ForkValue => {
5051
return value === 'yes' || value === 'no' || value === 'only';
5152
}
5253

54+
// Build a map for case-insensitive language lookup
55+
const languageKeyLowerCaseMap: Map<string, string> = new Map(
56+
Object.keys(languageMetadataMap).map(key => [key.toLowerCase(), key])
57+
);
58+
59+
/**
60+
* Finds the correct linguist language name from a case-insensitive input.
61+
* Returns the correctly-cased language name if found, otherwise returns the original input.
62+
*/
63+
const findLinguistLanguage = (value: string): string => {
64+
return languageKeyLowerCaseMap.get(value.toLowerCase()) ?? value;
65+
}
66+
5367
/**
5468
* Given a query string, parses it into the query intermediate representation.
5569
*/
@@ -269,13 +283,14 @@ const transformTreeToIR = async ({
269283
};
270284

271285

272-
case LangExpr:
286+
case LangExpr: {
273287
return {
274288
language: {
275-
language: value
289+
language: findLinguistLanguage(value)
276290
},
277291
query: "language"
278292
};
293+
}
279294

280295
case SymExpr:
281296
// Symbol search wraps a pattern

0 commit comments

Comments
 (0)