From 4208a74b360bc040b9d9179fdbb3b5de5ad23ee5 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 10 Dec 2019 18:43:48 -0300 Subject: [PATCH] 15921: Avoids adding a trailing slash to every resourceType. Updates API calls adding slashes where really needed. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/services/common-service/common-service.ts | 8 ++++---- src/services/common-service/trashable-resource-service.ts | 4 ++-- src/services/groups-service/groups-service.ts | 5 ++--- src/services/user-service/user-service.ts | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts index 212f2f4d03..1c1e0a569d 100644 --- a/src/services/common-service/common-service.ts +++ b/src/services/common-service/common-service.ts @@ -38,7 +38,7 @@ export class CommonService { constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions) { this.serverApi = serverApi; - this.resourceType = '/' + resourceType + '/'; + this.resourceType = '/' + resourceType; this.actions = actions; } @@ -93,7 +93,7 @@ export class CommonService { delete(uuid: string): Promise { return CommonService.defaultResponse( this.serverApi - .delete(this.resourceType + uuid), + .delete(this.resourceType + '/' + uuid), this.actions ); } @@ -101,7 +101,7 @@ export class CommonService { get(uuid: string) { return CommonService.defaultResponse( this.serverApi - .get(this.resourceType + uuid), + .get(this.resourceType + '/' + uuid), this.actions ); } @@ -125,7 +125,7 @@ export class CommonService { update(uuid: string, data: Partial) { return CommonService.defaultResponse( this.serverApi - .put(this.resourceType + uuid, data && CommonService.mapKeys(_.snakeCase)(data)), + .put(this.resourceType + '/' + uuid, data && CommonService.mapKeys(_.snakeCase)(data)), this.actions ); } diff --git a/src/services/common-service/trashable-resource-service.ts b/src/services/common-service/trashable-resource-service.ts index 633b2fbd89..5746bffb83 100644 --- a/src/services/common-service/trashable-resource-service.ts +++ b/src/services/common-service/trashable-resource-service.ts @@ -17,7 +17,7 @@ export class TrashableResourceService extends Commo trash(uuid: string): Promise { return CommonResourceService.defaultResponse( this.serverApi - .post(this.resourceType + `${uuid}/trash`), + .post(this.resourceType + `/${uuid}/trash`), this.actions ); } @@ -28,7 +28,7 @@ export class TrashableResourceService extends Commo }; return CommonResourceService.defaultResponse( this.serverApi - .post(this.resourceType + `${uuid}/untrash`, { + .post(this.resourceType + `/${uuid}/untrash`, { params: CommonResourceService.mapKeys(_.snakeCase)(params) }), this.actions diff --git a/src/services/groups-service/groups-service.ts b/src/services/groups-service/groups-service.ts index 691ab8f7cc..281aa92152 100644 --- a/src/services/groups-service/groups-service.ts +++ b/src/services/groups-service/groups-service.ts @@ -46,8 +46,7 @@ export class GroupsService extends Tras filters: filters ? `[${filters}]` : undefined, order: order ? order : undefined }; - - const pathUrl = uuid ? `${uuid}/contents` : 'contents'; + const pathUrl = uuid ? `/${uuid}/contents` : '/contents'; const cfg: AxiosRequestConfig = { params: CommonResourceService.mapKeys(_.snakeCase)(params) }; if (session) { @@ -65,7 +64,7 @@ export class GroupsService extends Tras shared(params: SharedArguments = {}): Promise> { return CommonResourceService.defaultResponse( this.serverApi - .get(this.resourceType + 'shared', { params }), + .get(this.resourceType + '/shared', { params }), this.actions ); } diff --git a/src/services/user-service/user-service.ts b/src/services/user-service/user-service.ts index ddb9a3646b..d8c7fe3d94 100644 --- a/src/services/user-service/user-service.ts +++ b/src/services/user-service/user-service.ts @@ -15,7 +15,7 @@ export class UserService extends CommonResourceService { activate(uuid: string) { return CommonResourceService.defaultResponse( this.serverApi - .post(this.resourceType + `${uuid}/activate`), + .post(this.resourceType + `/${uuid}/activate`), this.actions ); } @@ -23,7 +23,7 @@ export class UserService extends CommonResourceService { unsetup(uuid: string) { return CommonResourceService.defaultResponse( this.serverApi - .post(this.resourceType + uuid + '/unsetup'), + .post(this.resourceType + `/${uuid}/unsetup`), this.actions ); } -- 2.30.2