Skip to content

Commit

Permalink
[Windows:Plugins] Fixes the usage of normalizePath across node and …
Browse files Browse the repository at this point in the history
…browser

Signed-off-by: Miki <[email protected]>
  • Loading branch information
AMoo-Miki committed Oct 20, 2022
1 parent 1681add commit 31e3ded
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
* under the License.
*/

import { normalize } from 'path';
import { normalize, posix } from 'path';

export function normalizePath(path: string) {
// `normalize` in path-browserify is an implementation of `posix.normalize`
const normalizeFunc = posix?.normalize || normalize;
// resolve ../ within the path
const normalizedPath = normalize(path);
const normalizedPath = normalizeFunc(path);
// strip any leading slashes and dots and replace with single leading slash
return normalizedPath.replace(/(\.?\.?\/?)*/, '/');
}

0 comments on commit 31e3ded

Please sign in to comment.