nomagick commited on
Commit
4077fa7
·
unverified ·
1 Parent(s): 2941be6

fix: geoip encoding

Browse files
backend/functions/src/services/brave-search.ts CHANGED
@@ -37,7 +37,7 @@ export class BraveSearchService extends AsyncService {
37
  const geoip = await this.geoipControl.lookupCity(ip, GEOIP_SUPPORTED_LANGUAGES.EN);
38
 
39
  if (geoip?.city) {
40
- extraHeaders['X-Loc-City'] = geoip.city;
41
  }
42
  if (geoip?.country) {
43
  extraHeaders['X-Loc-Country'] = geoip.country.code;
@@ -50,8 +50,8 @@ export class BraveSearchService extends AsyncService {
50
  extraHeaders['X-Loc-Long'] = `${geoip.coordinates[1]}`;
51
  }
52
  if (geoip?.subdivisions?.length) {
53
- extraHeaders['X-Loc-State'] = geoip.subdivisions[0].code;
54
- extraHeaders['X-Loc-State-Name'] = geoip.subdivisions[0].name;
55
  }
56
  }
57
  if (this.threadLocal.get('userAgent')) {
 
37
  const geoip = await this.geoipControl.lookupCity(ip, GEOIP_SUPPORTED_LANGUAGES.EN);
38
 
39
  if (geoip?.city) {
40
+ extraHeaders['X-Loc-City'] = encodeURIComponent(geoip.city);
41
  }
42
  if (geoip?.country) {
43
  extraHeaders['X-Loc-Country'] = geoip.country.code;
 
50
  extraHeaders['X-Loc-Long'] = `${geoip.coordinates[1]}`;
51
  }
52
  if (geoip?.subdivisions?.length) {
53
+ extraHeaders['X-Loc-State'] = encodeURIComponent(`${geoip.subdivisions[0].code}`);
54
+ extraHeaders['X-Loc-State-Name'] = encodeURIComponent(`${geoip.subdivisions[0].name}`);
55
  }
56
  }
57
  if (this.threadLocal.get('userAgent')) {