mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 21:13:07 +00:00
Merge pull request #3876 from scholarsportal/fix-bitsream-filename-encoding-url-dspace-7_x
Fix redirect URLs of bitstreams with spaces in filename
This commit is contained in:
@@ -21,6 +21,7 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
|
|||||||
import objectContaining = jasmine.objectContaining;
|
import objectContaining = jasmine.objectContaining;
|
||||||
import { RemoteData } from './remote-data';
|
import { RemoteData } from './remote-data';
|
||||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { RequestParam } from '../cache/models/request-param.model';
|
||||||
|
|
||||||
describe('BitstreamDataService', () => {
|
describe('BitstreamDataService', () => {
|
||||||
let service: BitstreamDataService;
|
let service: BitstreamDataService;
|
||||||
@@ -132,4 +133,30 @@ describe('BitstreamDataService', () => {
|
|||||||
expect(service.invalidateByHref).toHaveBeenCalledWith('fake-bitstream2-self');
|
expect(service.invalidateByHref).toHaveBeenCalledWith('fake-bitstream2-self');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('findByItemHandle', () => {
|
||||||
|
it('should encode the filename correctly in the search parameters', () => {
|
||||||
|
const handle = '123456789/1234';
|
||||||
|
const sequenceId = '5';
|
||||||
|
const filename = 'file with spaces.pdf';
|
||||||
|
const searchParams = [
|
||||||
|
new RequestParam('handle', handle),
|
||||||
|
new RequestParam('sequenceId', sequenceId),
|
||||||
|
new RequestParam('filename', filename)
|
||||||
|
];
|
||||||
|
const linksToFollow: FollowLinkConfig<Bitstream>[] = [];
|
||||||
|
|
||||||
|
spyOn(service as any, 'getSearchByHref').and.callThrough();
|
||||||
|
|
||||||
|
service.getSearchByHref('byItemHandle', { searchParams }, ...linksToFollow).subscribe((href) => {
|
||||||
|
expect(service.getSearchByHref).toHaveBeenCalledWith(
|
||||||
|
'byItemHandle',
|
||||||
|
{ searchParams },
|
||||||
|
...linksToFollow
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(href).toBe(`${url}/bitstreams/search/byItemHandle?handle=123456789%2F1234&sequenceId=5&filename=file%20with%20spaces.pdf`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -171,7 +171,7 @@ export class BitstreamDataService extends IdentifiableDataService<Bitstream> imp
|
|||||||
searchParams.push(new RequestParam('sequenceId', sequenceId));
|
searchParams.push(new RequestParam('sequenceId', sequenceId));
|
||||||
}
|
}
|
||||||
if (hasValue(filename)) {
|
if (hasValue(filename)) {
|
||||||
searchParams.push(new RequestParam('filename', encodeURIComponent(filename)));
|
searchParams.push(new RequestParam('filename', filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
const hrefObs = this.getSearchByHref(
|
const hrefObs = this.getSearchByHref(
|
||||||
|
Reference in New Issue
Block a user