Skip to content

Commit

Permalink
fix(icherche): encode + correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Mar 29, 2021
1 parent 2267bed commit 02650a4
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/geo/src/lib/search/shared/sources/icherche.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, Inject, Injector } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpClient, HttpParams, HttpParameterCodec } from '@angular/common/http';

import { Observable, of, BehaviorSubject } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
Expand Down Expand Up @@ -36,6 +36,26 @@ export class IChercheSearchResultFormatter {
}
}

// Fix the "+" is replaced with space " " in a query string
// https://github.com/angular/angular/issues/11058
export class IgoHttpParameterCodec implements HttpParameterCodec {
encodeKey(key: string): string {
return encodeURIComponent(key);
}

encodeValue(value: string): string {
return encodeURIComponent(value);
}

decodeKey(key: string): string {
return decodeURIComponent(key);
}

decodeValue(value: string): string {
return decodeURIComponent(value);
}
}

/**
* ICherche search source
*/
Expand Down Expand Up @@ -388,7 +408,8 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
}

return new HttpParams({
fromObject: ObjectUtils.removeUndefined(queryParams)
fromObject: ObjectUtils.removeUndefined(queryParams),
encoder: new IgoHttpParameterCodec()
});
}

Expand Down

0 comments on commit 02650a4

Please sign in to comment.