From 5dd40c1c83bcbc3efcb26fe73f6ceb0342933cbf Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Wed, 13 Nov 2019 13:59:06 -0500 Subject: [PATCH] Replaces unnecessary regex with plain old string search --- src/app/_services/api/api.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/_services/api/api.service.ts b/src/app/_services/api/api.service.ts index 358b897..df4c230 100644 --- a/src/app/_services/api/api.service.ts +++ b/src/app/_services/api/api.service.ts @@ -111,7 +111,12 @@ export class ApiService { } private _dummy_api_url(path: string) { - return path.replace(/^(.*)\/api\/(.*)$/, '/assets/json/$2.json'); + if (path.search('/api/') !== -1) { + const arr = path.split('/api/'); + if (arr.length > 0) { + return `/assets/json/${arr[arr.length - 1]}.json`; + } + } } private _getOne(id: number, endpointName: string): Observable {