77583: Specify id type ~ /api/pid/find?id=hdl:...

This commit is contained in:
Yura Bondarenko
2021-03-16 14:30:59 +01:00
parent d1ab193f5d
commit 6fabf436e3
2 changed files with 4 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ describe('LookupGuard', () => {
} }
}; };
guard.canActivate(scopedRoute as any, undefined); guard.canActivate(scopedRoute as any, undefined);
expect(dsoService.findByIdAndIDType).toHaveBeenCalledWith('123456789/1234', IdentifierType.HANDLE); expect(dsoService.findByIdAndIDType).toHaveBeenCalledWith('hdl:123456789/1234', IdentifierType.HANDLE);
}); });
it('should call findByIdAndIDType with handle params', () => { it('should call findByIdAndIDType with handle params', () => {
@@ -33,7 +33,7 @@ describe('LookupGuard', () => {
} }
}; };
guard.canActivate(scopedRoute as any, undefined); guard.canActivate(scopedRoute as any, undefined);
expect(dsoService.findByIdAndIDType).toHaveBeenCalledWith('123456789%2F1234', IdentifierType.HANDLE); expect(dsoService.findByIdAndIDType).toHaveBeenCalledWith('hdl:123456789%2F1234', IdentifierType.HANDLE);
}); });
it('should call findByIdAndIDType with UUID params', () => { it('should call findByIdAndIDType with UUID params', () => {

View File

@@ -35,11 +35,11 @@ export class LookupGuard implements CanActivate {
type = IdentifierType.HANDLE; type = IdentifierType.HANDLE;
const prefix = route.params.idType; const prefix = route.params.idType;
const handleId = route.params.id; const handleId = route.params.id;
id = `${prefix}/${handleId}`; id = `hdl:${prefix}/${handleId}`;
} else if (route.params.idType === IdentifierType.HANDLE) { } else if (route.params.idType === IdentifierType.HANDLE) {
type = IdentifierType.HANDLE; type = IdentifierType.HANDLE;
id = route.params.id; id = 'hdl:' + route.params.id;
} else { } else {
type = IdentifierType.UUID; type = IdentifierType.UUID;