Skip to content

Commit

Permalink
jsc/wasm32/wasm32.jsc: normalize path
Browse files Browse the repository at this point in the history
  • Loading branch information
pipcet committed Feb 1, 2021
1 parent b3d100f commit 6891c9c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions jsc/wasm32/wasm32.jsc
Original file line number Diff line number Diff line change
Expand Up @@ -5474,9 +5474,19 @@ ThinThin.chdir = function (ptr)
{
var path = CStringAt(this.HEAPU8, ptr);
if (path === "./")
this.pwd = ".";
else
this.pwd += "/" + path;
path = "..";
//if (path === "./")
//this.pwd = ".";
//else
this.pwd += "/" + path;
while (this.pwd.match(/\/\.\.\//))
this.pwd = this.pwd.replace(/\/([^/]+)\/\.\.\//, "/");
while (this.pwd.match(/\/\.\.$/))
this.pwd = this.pwd.replace(/\/([^/]+)\/\.\.$/, "/");
while (this.pwd.match(/\/\//))
this.pwd = this.pwd.replace(/\/\//, "/");
while (this.pwd.match(/\/$/))
this.pwd = this.pwd.replace(/\/$/, "");
return Promise.resolve(0);
};

Expand Down

0 comments on commit 6891c9c

Please sign in to comment.