nomagick commited on
Commit
f472f02
·
unverified ·
1 Parent(s): 2073c40

fix: country code validation

Browse files
Files changed (1) hide show
  1. src/api/searcher-serper.ts +2 -2
src/api/searcher-serper.ts CHANGED
@@ -23,7 +23,7 @@ import { InsufficientBalanceError } from '../services/errors';
23
  import { SerperImageSearchResponse, SerperNewsSearchResponse, SerperSearchQueryParams, SerperSearchResponse, SerperWebSearchResponse, WORLD_COUNTRIES, WORLD_LANGUAGES } from '../shared/3rd-party/serper-search';
24
  import { toAsyncGenerator } from '../utils/misc';
25
 
26
- const WORLD_COUNTRY_CODES = Object.keys(WORLD_COUNTRIES);
27
 
28
  interface FormattedPage extends RealFormattedPage {
29
  favicon?: string;
@@ -94,7 +94,7 @@ export class SearcherHost extends RPCHost {
94
  searchEngine: 'google' | 'bing',
95
  @Param('num', { validate: (v: number) => v >= 0 && v <= 20 })
96
  num?: number,
97
- @Param('gl', { validate: (v: string) => WORLD_COUNTRY_CODES.includes(v) }) gl?: string,
98
  @Param('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string,
99
  @Param('location') location?: string,
100
  @Param('page') page?: number,
 
23
  import { SerperImageSearchResponse, SerperNewsSearchResponse, SerperSearchQueryParams, SerperSearchResponse, SerperWebSearchResponse, WORLD_COUNTRIES, WORLD_LANGUAGES } from '../shared/3rd-party/serper-search';
24
  import { toAsyncGenerator } from '../utils/misc';
25
 
26
+ const WORLD_COUNTRY_CODES = Object.keys(WORLD_COUNTRIES).map((x) => x.toLowerCase());
27
 
28
  interface FormattedPage extends RealFormattedPage {
29
  favicon?: string;
 
94
  searchEngine: 'google' | 'bing',
95
  @Param('num', { validate: (v: number) => v >= 0 && v <= 20 })
96
  num?: number,
97
+ @Param('gl', { validate: (v: string) => WORLD_COUNTRY_CODES.includes(v?.toLowerCase()) }) gl?: string,
98
  @Param('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string,
99
  @Param('location') location?: string,
100
  @Param('page') page?: number,