79698: Escape browse by author data requests

This commit is contained in:
Bruno Roemers
2021-05-28 15:40:20 +02:00
parent f85a5e65ad
commit 4ad089ef54
2 changed files with 4 additions and 3 deletions

View File

@@ -127,7 +127,8 @@ describe('BrowseService', () => {
}); });
describe('getBrowseEntriesFor and findList', () => { describe('getBrowseEntriesFor and findList', () => {
const mockAuthorName = 'Donald Smith'; // should contain special characters such that url encoding can be tested as well
const mockAuthorName = 'Donald Smith & Sons';
beforeEach(() => { beforeEach(() => {
requestService = getMockRequestService(getRequestEntry$(true)); requestService = getMockRequestService(getRequestEntry$(true));
@@ -152,7 +153,7 @@ describe('BrowseService', () => {
describe('when findList is called with a valid browse definition id', () => { describe('when findList is called with a valid browse definition id', () => {
it('should call hrefOnlyDataService.findAllByHref with the expected href', () => { it('should call hrefOnlyDataService.findAllByHref with the expected href', () => {
const expected = browseDefinitions[1]._links.items.href + '?filterValue=' + mockAuthorName; const expected = browseDefinitions[1]._links.items.href + '?filterValue=' + encodeURIComponent(mockAuthorName);
scheduler.schedule(() => service.getBrowseItemsFor(mockAuthorName, new BrowseEntrySearchOptions(browseDefinitions[1].id)).subscribe()); scheduler.schedule(() => service.getBrowseItemsFor(mockAuthorName, new BrowseEntrySearchOptions(browseDefinitions[1].id)).subscribe());
scheduler.flush(); scheduler.flush();

View File

@@ -130,7 +130,7 @@ export class BrowseService {
args.push(`startsWith=${options.startsWith}`); args.push(`startsWith=${options.startsWith}`);
} }
if (isNotEmpty(filterValue)) { if (isNotEmpty(filterValue)) {
args.push(`filterValue=${filterValue}`); args.push(`filterValue=${encodeURIComponent(filterValue)}`);
} }
if (isNotEmpty(args)) { if (isNotEmpty(args)) {
href = new URLCombiner(href, `?${args.join('&')}`).toString(); href = new URLCombiner(href, `?${args.join('&')}`).toString();