fix search percent character handling (#3916)

This commit is contained in:
Denys Vuika
2024-07-09 08:09:57 -04:00
committed by GitHub
parent 1e4d055b87
commit 4ecadf4237
2 changed files with 9 additions and 1 deletions

View File

@@ -76,6 +76,14 @@ describe('SearchEffects', () => {
expect(router.navigateByUrl).toHaveBeenCalledWith('/search;q=%2528test%2529');
}));
it('should encode %', fakeAsync(() => {
store.dispatch(new SearchByTermAction('%test%', []));
tick();
expect(router.navigateByUrl).toHaveBeenCalledWith('/search;q=%2525test%2525');
}));
});
describe('search$', () => {

View File

@@ -49,7 +49,7 @@ export class SearchEffects {
this.actions$.pipe(
ofType<SearchByTermAction>(SearchActionTypes.SearchByTerm),
map((action) => {
const query = action.payload.replace(/[(]/g, '%28').replace(/[)]/g, '%29');
const query = action.payload.replace(/%/g, '%25').replace(/[(]/g, '%28').replace(/[)]/g, '%29');
const libItem = action.searchOptions.find((item) => item.id === SearchOptionIds.Libraries);
const librarySelected = !!libItem && libItem.value;