diff --git a/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.html b/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.html index b4610c6815..9774ba8445 100644 --- a/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.html +++ b/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.html @@ -27,11 +27,11 @@

Create a new workspace

- {{ ngNewForm.value.path }}/{{ control.value }} already exists + {{ ngNewForm.value.path + "/" + control.value | normalizePath }} already exists create_new_folder - Workspace path will be {{ ngNewForm.value.path }}/{{ control.value }} + Workspace path will be {{ ngNewForm.value.path + "/" + control.value | normalizePath }} diff --git a/libs/ui/src/lib/normalize-path.pipe.spec.ts b/libs/ui/src/lib/normalize-path.pipe.spec.ts index d9a21ce175..ad53ff20d9 100644 --- a/libs/ui/src/lib/normalize-path.pipe.spec.ts +++ b/libs/ui/src/lib/normalize-path.pipe.spec.ts @@ -18,5 +18,6 @@ describe('NormalizePathPipe', () => { expect(pipe.transform('C:')).toEqual('C:'); expect(pipe.transform('C://')).toEqual('C:'); expect(pipe.transform('C://one/two')).toEqual('C:\\one\\two'); + expect(pipe.transform('C:\\one/two')).toEqual('C:\\one\\two'); }); }); diff --git a/libs/ui/src/lib/normalize-path.pipe.ts b/libs/ui/src/lib/normalize-path.pipe.ts index 05f6c35b66..7b8e3996a1 100644 --- a/libs/ui/src/lib/normalize-path.pipe.ts +++ b/libs/ui/src/lib/normalize-path.pipe.ts @@ -5,9 +5,20 @@ import { Pipe, PipeTransform } from '@angular/core'; }) export class NormalizePathPipe implements PipeTransform { transform(value: string, args?: any): any { - const firstPart = value.split('/')[0]; - if (!firstPart) return value; - if (!firstPart.endsWith(':')) return value; + const firstPartIfWin = value.split('\\')[0]; + if (firstPartIfWin && firstPartIfWin.endsWith(':')) { + return this.toWin(value); + } + + const firstPartIfUnix = value.split('/')[0]; + if (firstPartIfUnix && firstPartIfUnix.endsWith(':')) { + return this.toWin(value); + } + + return value; + } + + private toWin(value: string) { return value .replace(new RegExp('/', 'g'), '\\') .split('\\')