From 0315270e987f577dbc210cf401201f2bbf27b5fb Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Mon, 19 Jun 2017 15:18:32 +0200 Subject: [PATCH] Modified the 'FSPath' to remove '//' sequences ('//' => '/') --- lib/manager/FSPath.js | 9 +++++++-- src/manager/FSPath.ts | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/manager/FSPath.js b/lib/manager/FSPath.js index 3568acbe..a8e04c20 100644 --- a/lib/manager/FSPath.js +++ b/lib/manager/FSPath.js @@ -2,8 +2,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); var FSPath = (function () { function FSPath(path) { - if (path.constructor === String) - this.paths = path.replace(/(^\/|\/$)/g, '').split('/'); + if (path.constructor === String) { + var sPath = path; + var doubleIndex = void 0; + while ((doubleIndex = sPath.indexOf('//')) !== -1) + sPath = sPath.substr(0, doubleIndex) + sPath.substr(doubleIndex + 1); + this.paths = sPath.replace(/(^\/|\/$)/g, '').split('/'); + } else if (path.constructor === FSPath) this.paths = path.paths.filter(function (x) { return true; }); else diff --git a/src/manager/FSPath.ts b/src/manager/FSPath.ts index 7eba7777..1e5e0846 100644 --- a/src/manager/FSPath.ts +++ b/src/manager/FSPath.ts @@ -6,7 +6,13 @@ export class FSPath constructor(path : FSPath | string[] | string) { if(path.constructor === String) - this.paths = (path as string).replace(/(^\/|\/$)/g, '').split('/'); + { + let sPath = (path as string); + let doubleIndex; + while((doubleIndex = sPath.indexOf('//')) !== -1) + sPath = sPath.substr(0, doubleIndex) + sPath.substr(doubleIndex + 1); + this.paths = sPath.replace(/(^\/|\/$)/g, '').split('/'); + } else if(path.constructor === FSPath) this.paths = (path as FSPath).paths.filter((x) => true); // clone else