From 992f929e48aee9ea29a722981801f6376de426c4 Mon Sep 17 00:00:00 2001 From: qun <68707557+L-Qun@users.noreply.github.com> Date: Tue, 5 Mar 2024 03:38:45 +0000 Subject: [PATCH] chore: use path.parse instead of split --- apps/sparo-lib/src/services/SparoProfileService.ts | 8 ++------ common/changes/sparo/main_2024-03-05-03-36.json | 10 ++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 common/changes/sparo/main_2024-03-05-03-36.json diff --git a/apps/sparo-lib/src/services/SparoProfileService.ts b/apps/sparo-lib/src/services/SparoProfileService.ts index a5208b1..665c89d 100644 --- a/apps/sparo-lib/src/services/SparoProfileService.ts +++ b/apps/sparo-lib/src/services/SparoProfileService.ts @@ -107,12 +107,8 @@ export class SparoProfileService { } private static _getProfileName(profilePath: string): string { - const pathArr: string[] = profilePath.split(path.sep); - const last: string = pathArr[pathArr.length - 1]; - if (last.endsWith('.json')) { - return last.slice(0, -5); - } - return last; + const parsed: path.ParsedPath = path.parse(profilePath); + return parsed.name; } public async resolveSparoProfileAsync( diff --git a/common/changes/sparo/main_2024-03-05-03-36.json b/common/changes/sparo/main_2024-03-05-03-36.json new file mode 100644 index 0000000..6b6ce60 --- /dev/null +++ b/common/changes/sparo/main_2024-03-05-03-36.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "sparo", + "comment": "", + "type": "none" + } + ], + "packageName": "sparo" +} \ No newline at end of file