@@ -28,6 +28,7 @@ import { SINGLE_TENANT_ORG_ID } from '@/lib/constants';
2828import { ServiceErrorException } from '@/lib/serviceError' ;
2929import { StatusCodes } from 'http-status-codes' ;
3030import { ErrorCode } from '@/lib/errorCodes' ;
31+ import { languageMetadataMap } from '@/lib/languageMetadata' ;
3132
3233// Configure the parser to throw errors when encountering invalid syntax.
3334const 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