Skip to content

Commit

Permalink
Merge pull request #3885 from tdonohue/port_3876_to_8x
Browse files Browse the repository at this point in the history
[Port dspace-8_x] Fix redirect URLs of bitstreams with spaces in filename (new test ONLY)
  • Loading branch information
tdonohue authored Jan 23, 2025
2 parents 2a5d779 + 19db3fa commit d23483d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/app/core/data/bitstream-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { RequestParam } from '../cache/models/request-param.model';
import { ObjectCacheService } from '../cache/object-cache.service';
import { Bitstream } from '../shared/bitstream.model';
import { BitstreamFormat } from '../shared/bitstream-format.model';
Expand Down Expand Up @@ -176,4 +177,30 @@ describe('BitstreamDataService', () => {
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`);
});
});
});
});

0 comments on commit d23483d

Please sign in to comment.