diff --git a/jsc/wasm32/wasm32.jsc b/jsc/wasm32/wasm32.jsc index 7082c0b7..8145bab4 100644 --- a/jsc/wasm32/wasm32.jsc +++ b/jsc/wasm32/wasm32.jsc @@ -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); };