Skip to content

Commit 28c37b3

Browse files
authored
[ENG-10139] The preprint cannot be opened from the search page (#862)
- Ticket: [ENG-10139] - Feature flag: n/a ## Summary of Changes 1. Fix guard logic for preprints.
1 parent c9b6623 commit 28c37b3

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/app/core/guards/is-project.guard.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('isProjectGuard', () => {
142142

143143
it('should navigate and return true for Projects with parentId', (done) => {
144144
const resource = createMockResource({
145-
id: 'parent-id',
145+
id: 'parent-id/child-id',
146146
type: CurrentResourceType.Projects,
147147
parentId: 'parent-id',
148148
});
@@ -241,7 +241,7 @@ describe('isProjectGuard', () => {
241241

242242
it('should navigate and return true for Preprints with parentId', (done) => {
243243
const resource = createMockResource({
244-
id: 'parent-id',
244+
id: 'parent-id/child-id',
245245
type: CurrentResourceType.Preprints,
246246
parentId: 'parent-id',
247247
});

src/app/core/guards/is-project.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const isProjectGuard: CanMatchFn = (route: Route, segments: UrlSegment[])
2222
return store.dispatch(new GetResource(id)).pipe(
2323
switchMap(() => store.select(CurrentResourceSelectors.getCurrentResource)),
2424
map((resource) => {
25-
if (!resource || !id.startsWith(resource.id)) {
25+
if (!resource || !resource.id.startsWith(id)) {
2626
return false;
2727
}
2828

src/app/core/guards/is-registry.guard.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('isRegistryGuard', () => {
142142

143143
it('should navigate and return true for Registrations with parentId', (done) => {
144144
const resource = createMockResource({
145-
id: 'parent-id',
145+
id: 'parent-id/child-id',
146146
type: CurrentResourceType.Registrations,
147147
parentId: 'parent-id',
148148
});
@@ -241,7 +241,7 @@ describe('isRegistryGuard', () => {
241241

242242
it('should navigate and return true for Preprints with parentId', (done) => {
243243
const resource = createMockResource({
244-
id: 'parent-id',
244+
id: 'parent-id/child-id',
245245
type: CurrentResourceType.Preprints,
246246
parentId: 'parent-id',
247247
});

src/app/core/guards/is-registry.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const isRegistryGuard: CanMatchFn = (route: Route, segments: UrlSegment[]
2222
return store.dispatch(new GetResource(id)).pipe(
2323
switchMap(() => store.select(CurrentResourceSelectors.getCurrentResource)),
2424
map((resource) => {
25-
if (!resource || !id.startsWith(resource.id)) {
25+
if (!resource || !resource.id.startsWith(id)) {
2626
return false;
2727
}
2828

0 commit comments

Comments
 (0)