From 7c80aebe75be3b01ec3523c626bca30a3227d01e Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 9 May 2019 18:22:29 +0200 Subject: [PATCH] Added beginning slash to all request urls --- client/src/app/core/core-services/data-send.service.ts | 8 ++++---- client/src/app/core/core-services/http.service.ts | 4 ++++ client/src/app/core/core-services/time-travel.service.ts | 3 +-- .../repositories/agenda/speaker-repository.service.ts | 2 +- .../core/repositories/config/config-repository.service.ts | 2 +- .../repositories/history/history-repository.service.ts | 2 +- .../mediafiles/mediafile-repository.service.ts | 3 +-- .../repositories/motions/category-repository.service.ts | 6 ++---- .../motions/motion-comment-section-repository.service.ts | 4 ++-- .../repositories/motions/workflow-repository.service.ts | 2 +- .../core/repositories/users/user-repository.service.ts | 2 +- client/src/app/core/ui-services/media-manage.service.ts | 2 +- client/src/app/core/ui-services/personal-note.service.ts | 4 ++-- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/client/src/app/core/core-services/data-send.service.ts b/client/src/app/core/core-services/data-send.service.ts index f3a362cf5..4a85a5715 100644 --- a/client/src/app/core/core-services/data-send.service.ts +++ b/client/src/app/core/core-services/data-send.service.ts @@ -26,7 +26,7 @@ export class DataSendService { * @param model The model to create. */ public async createModel(model: BaseModel): Promise { - const restPath = `rest/${model.collectionString}/`; + const restPath = `/rest/${model.collectionString}/`; return await this.httpService.post(restPath, model); } @@ -36,7 +36,7 @@ export class DataSendService { * @param model The model that is meant to be changed. */ public async updateModel(model: BaseModel): Promise { - const restPath = `rest/${model.collectionString}/${model.id}/`; + const restPath = `/rest/${model.collectionString}/${model.id}/`; await this.httpService.put(restPath, model); } @@ -46,7 +46,7 @@ export class DataSendService { * @param model The model to partially update. */ public async partialUpdateModel(model: BaseModel): Promise { - const restPath = `rest/${model.collectionString}/${model.id}/`; + const restPath = `/rest/${model.collectionString}/${model.id}/`; await this.httpService.patch(restPath, model); } @@ -56,7 +56,7 @@ export class DataSendService { * @param model the model that shall be deleted. */ public async deleteModel(model: BaseModel): Promise { - const restPath = `rest/${model.collectionString}/${model.id}/`; + const restPath = `/rest/${model.collectionString}/${model.id}/`; await this.httpService.delete(restPath); } } diff --git a/client/src/app/core/core-services/http.service.ts b/client/src/app/core/core-services/http.service.ts index 0265000d7..0866cf0b5 100644 --- a/client/src/app/core/core-services/http.service.ts +++ b/client/src/app/core/core-services/http.service.ts @@ -79,6 +79,10 @@ export class HttpService { } let url = path + formatQueryParams(queryParams); + if (url[0] !== '/') { + console.warn(`Please prefix the URL "${url}" with a slash.`); + url = '/' + url; + } if (this.OSStatus.isPrioritizedClient) { url = '/prioritize' + url; } diff --git a/client/src/app/core/core-services/time-travel.service.ts b/client/src/app/core/core-services/time-travel.service.ts index a9fa1b0f6..95498c0d5 100644 --- a/client/src/app/core/core-services/time-travel.service.ts +++ b/client/src/app/core/core-services/time-travel.service.ts @@ -94,9 +94,8 @@ export class TimeTravelService { * @returns the full history on the given date */ private async getHistoryData(history: History): Promise { - const historyUrl = '/core/history/'; const queryParams = { timestamp: Math.ceil(+history.unixtime) }; - return this.httpService.get(environment.urlPrefix + historyUrl, null, queryParams); + return this.httpService.get(`${environment.urlPrefix}/core/history/`, null, queryParams); } /** diff --git a/client/src/app/core/repositories/agenda/speaker-repository.service.ts b/client/src/app/core/repositories/agenda/speaker-repository.service.ts index f7dddad45..96ae27a2d 100644 --- a/client/src/app/core/repositories/agenda/speaker-repository.service.ts +++ b/client/src/app/core/repositories/agenda/speaker-repository.service.ts @@ -158,6 +158,6 @@ export class SpeakerRepositoryService { * @param suffix the desired speaker action */ private getRestUrl(itemId: number, suffix: SpeakerAction): string { - return `rest/agenda/item/${itemId}/${suffix}/`; + return `/rest/agenda/item/${itemId}/${suffix}/`; } } diff --git a/client/src/app/core/repositories/config/config-repository.service.ts b/client/src/app/core/repositories/config/config-repository.service.ts index 505ab062f..9bf92ddeb 100644 --- a/client/src/app/core/repositories/config/config-repository.service.ts +++ b/client/src/app/core/repositories/config/config-repository.service.ts @@ -266,7 +266,7 @@ export class ConfigRepositoryService extends BaseRepository updatedConfig.patchValues(viewConfig.config); updatedConfig.patchValues(config); // TODO: Use datasendService, if it can switch correctly between put, post and patch - await this.http.put('rest/' + updatedConfig.collectionString + '/' + updatedConfig.key + '/', updatedConfig); + await this.http.put(`/rest/${updatedConfig.collectionString}/${updatedConfig.key}/`, updatedConfig); } /** diff --git a/client/src/app/core/repositories/history/history-repository.service.ts b/client/src/app/core/repositories/history/history-repository.service.ts index d6b320eee..c552ed9f0 100644 --- a/client/src/app/core/repositories/history/history-repository.service.ts +++ b/client/src/app/core/repositories/history/history-repository.service.ts @@ -109,7 +109,7 @@ export class HistoryRepositoryService extends BaseRepository { - const restPath = 'rest/core/history/clear_history/'; + const restPath = '/rest/core/history/clear_history/'; await this.httpService.post(restPath); } diff --git a/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts b/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts index 5a30f63e0..60ba9beb1 100644 --- a/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts +++ b/client/src/app/core/repositories/mediafiles/mediafile-repository.service.ts @@ -66,9 +66,8 @@ export class MediafileRepositoryService extends BaseRepository { - const restPath = `rest/mediafiles/mediafile/`; const emptyHeader = new HttpHeaders(); - return this.httpService.post(restPath, file, {}, emptyHeader); + return this.httpService.post('`/rest/mediafiles/mediafile/', file, {}, emptyHeader); } /** diff --git a/client/src/app/core/repositories/motions/category-repository.service.ts b/client/src/app/core/repositories/motions/category-repository.service.ts index 836348d12..0bcac6f3e 100644 --- a/client/src/app/core/repositories/motions/category-repository.service.ts +++ b/client/src/app/core/repositories/motions/category-repository.service.ts @@ -77,8 +77,7 @@ export class CategoryRepositoryService extends BaseRepository { - const collectionString = 'rest/motions/category/' + category.id + '/numbering/'; - await this.httpService.post(collectionString, { motions: motionIds }); + await this.httpService.post(`/rest/motions/category/${category.id}/numbering/`, { motions: motionIds }); } /** @@ -88,8 +87,7 @@ export class CategoryRepositoryService extends BaseRepository { - const collectionString = 'rest/motions/category/' + category.id + '/sort/'; - await this.httpService.post(collectionString, { motions: motionIds }); + await this.httpService.post(`/rest/motions/category/${category.id}/sort/`, { motions: motionIds }); } /** diff --git a/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts b/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts index 64260501e..bf546746a 100644 --- a/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-comment-section-repository.service.ts @@ -90,7 +90,7 @@ export class MotionCommentSectionRepositoryService extends BaseRepository< * Updates the comment. Saves it on the server. */ private async updateComment(motion: ViewMotion, section: ViewMotionCommentSection, comment: string): Promise { - return await this.http.post(`rest/motions/motion/${motion.id}/manage_comments/`, { + return await this.http.post(`/rest/motions/motion/${motion.id}/manage_comments/`, { section_id: section.id, comment: comment }); @@ -100,6 +100,6 @@ export class MotionCommentSectionRepositoryService extends BaseRepository< * Deletes a comment from the server */ private async deleteComment(motion: ViewMotion, section: ViewMotionCommentSection): Promise { - return await this.http.delete(`rest/motions/motion/${motion.id}/manage_comments/`, { section_id: section.id }); + return await this.http.delete(`/rest/motions/motion/${motion.id}/manage_comments/`, { section_id: section.id }); } } diff --git a/client/src/app/core/repositories/motions/workflow-repository.service.ts b/client/src/app/core/repositories/motions/workflow-repository.service.ts index 5f4587a35..de76550d3 100644 --- a/client/src/app/core/repositories/motions/workflow-repository.service.ts +++ b/client/src/app/core/repositories/motions/workflow-repository.service.ts @@ -29,7 +29,7 @@ export class WorkflowRepositoryService extends BaseRepository { const data = newEntries.map(entry => { return { ...entry.newEntry.user, importTrackId: entry.importTrackId }; }); - const response = (await this.httpService.post(`rest/users/user/mass_import/`, { users: data })) as { + const response = (await this.httpService.post(`/rest/users/user/mass_import/`, { users: data })) as { detail: string; importedTrackIds: number[]; }; diff --git a/client/src/app/core/ui-services/media-manage.service.ts b/client/src/app/core/ui-services/media-manage.service.ts index b98957b83..ce5871e56 100644 --- a/client/src/app/core/ui-services/media-manage.service.ts +++ b/client/src/app/core/ui-services/media-manage.service.ts @@ -60,7 +60,7 @@ export class MediaManageService { * @param action determines the action */ public async setAs(file: ViewMediafile, action: string): Promise { - const restPath = `rest/core/config/${action}/`; + const restPath = `/rest/core/config/${action}/`; const config = this.getMediaConfig(action); const path = config.path !== file.downloadUrl ? file.downloadUrl : ''; diff --git a/client/src/app/core/ui-services/personal-note.service.ts b/client/src/app/core/ui-services/personal-note.service.ts index a53529174..d6852173e 100644 --- a/client/src/app/core/ui-services/personal-note.service.ts +++ b/client/src/app/core/ui-services/personal-note.service.ts @@ -95,9 +95,9 @@ export class PersonalNoteService { */ private async savePersonalNoteObject(pnObject: Partial): Promise { if (!pnObject.id) { - await this.http.post('rest/users/personal-note/', pnObject); + await this.http.post('/rest/users/personal-note/', pnObject); } else { - await this.http.put(`rest/users/personal-note/${pnObject.id}/`, pnObject); + await this.http.put(`/rest/users/personal-note/${pnObject.id}/`, pnObject); } } }