Skip to content

Commit 84bdfb8

Browse files
committed
94060: Encoded embedded slash forward to prevent cypress glob issues
1 parent fb9ed87 commit 84bdfb8

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/app/core/data/base/base-data.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ObjectCacheEntry } from '../../cache/object-cache.reducer';
2424
import { ObjectCacheService } from '../../cache/object-cache.service';
2525
import { HALDataService } from './hal-data-service.interface';
2626

27+
export const EMBED_SEPARATOR = '%2F';
2728
/**
2829
* Common functionality for data services.
2930
* Specific functionality that not all services would need
@@ -201,7 +202,7 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
201202
let nestEmbed = embedString;
202203
linksToFollow.forEach((linkToFollow: FollowLinkConfig<T>) => {
203204
if (hasValue(linkToFollow) && linkToFollow.shouldEmbed) {
204-
nestEmbed = nestEmbed + '/' + String(linkToFollow.name);
205+
nestEmbed = nestEmbed + EMBED_SEPARATOR + String(linkToFollow.name);
205206
// Add the nested embeds size if given in the FollowLinkConfig.FindListOptions
206207
if (hasValue(linkToFollow.findListOptions) && hasValue(linkToFollow.findListOptions.elementsPerPage)) {
207208
const nestedEmbedSize = 'embed.size=' + nestEmbed.split('=')[1] + '=' + linkToFollow.findListOptions.elementsPerPage;

src/app/core/data/base/find-all-data.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.s
2222
import { HALEndpointService } from '../../shared/hal-endpoint.service';
2323
import { ObjectCacheService } from '../../cache/object-cache.service';
2424
import { Observable, of as observableOf } from 'rxjs';
25+
import { EMBED_SEPARATOR } from './base-data.service';
2526

2627
/**
2728
* Tests whether calls to `FindAllData` methods are correctly patched through in a concrete data service that implements it
@@ -276,15 +277,15 @@ describe('FindAllDataImpl', () => {
276277
});
277278

278279
it('should include nested linksToFollow 3lvl', () => {
279-
const expected = `${endpoint}?embed=owningCollection/itemtemplate/relationships`;
280+
const expected = `${endpoint}?embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
280281

281282
(service as any).getFindAllHref({}, null, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships')))).subscribe((value) => {
282283
expect(value).toBe(expected);
283284
});
284285
});
285286

286287
it('should include nested linksToFollow 2lvl and nested embed\'s size', () => {
287-
const expected = `${endpoint}?embed.size=owningCollection/itemtemplate=4&embed=owningCollection/itemtemplate`;
288+
const expected = `${endpoint}?embed.size=owningCollection${EMBED_SEPARATOR}itemtemplate=4&embed=owningCollection${EMBED_SEPARATOR}itemtemplate`;
288289
const config: FindListOptions = Object.assign(new FindListOptions(), {
289290
elementsPerPage: 4,
290291
});

src/app/core/data/base/identifiable-data.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.s
1919
import { HALEndpointService } from '../../shared/hal-endpoint.service';
2020
import { ObjectCacheService } from '../../cache/object-cache.service';
2121
import { IdentifiableDataService } from './identifiable-data.service';
22+
import { EMBED_SEPARATOR } from './base-data.service';
2223

2324
const endpoint = 'https://rest.api/core';
2425

@@ -137,7 +138,7 @@ describe('IdentifiableDataService', () => {
137138
});
138139

139140
it('should include nested linksToFollow 3lvl', () => {
140-
const expected = `${endpointMock}/${resourceIdMock}?embed=owningCollection/itemtemplate/relationships`;
141+
const expected = `${endpointMock}/${resourceIdMock}?embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
141142
const result = (service as any).getIDHref(endpointMock, resourceIdMock, followLink('owningCollection', {}, followLink('itemtemplate', {}, followLink('relationships'))));
142143
expect(result).toEqual(expected);
143144
});

src/app/core/data/dso-redirect.service.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { GetRequest, IdentifierType } from './request.models';
99
import { RequestService } from './request.service';
1010
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
1111
import { Item } from '../shared/item.model';
12+
import { EMBED_SEPARATOR } from './base/base-data.service';
1213

1314
describe('DsoRedirectService', () => {
1415
let scheduler: TestScheduler;
@@ -174,7 +175,7 @@ describe('DsoRedirectService', () => {
174175
});
175176

176177
it('should include nested linksToFollow 3lvl', () => {
177-
const expected = `${requestUUIDURL}&embed=owningCollection/itemtemplate/relationships`;
178+
const expected = `${requestUUIDURL}&embed=owningCollection${EMBED_SEPARATOR}itemtemplate${EMBED_SEPARATOR}relationships`;
178179
const result = (service as any).dataService.getIDHref(
179180
pidLink,
180181
dsoUUID,

0 commit comments

Comments
 (0)