@@ -172,15 +172,17 @@ FS.staticInit();
172172 // paths
173173 //
174174 lookupPath ( path , opts = { } ) {
175- path = PATH_FS . resolve ( path ) ;
176-
177175 if ( ! path ) return { path : '' , node : null } ;
178176 opts . follow_mount ??= true
179177
178+ if ( ! PATH . isAbs ( path ) ) {
179+ path = FS . cwd ( ) + '/' + path ;
180+ }
181+
180182 // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
181183 linkloop : for ( var nlinks = 0 ; nlinks < 40 ; nlinks ++ ) {
182184 // split the absolute path
183- var parts = path . split ( '/' ) . filter ( ( p ) => ! ! p ) ;
185+ var parts = path . split ( '/' ) . filter ( ( p ) => ! ! p && ( p !== '.' ) ) ;
184186
185187 // start at the root
186188 var current = FS . root ;
@@ -193,6 +195,12 @@ FS.staticInit();
193195 break;
194196 }
195197
198+ if ( parts [ i ] === '..' ) {
199+ current_path = PATH . dirname ( current_path ) ;
200+ current = current . parent ;
201+ continue ;
202+ }
203+
196204 current_path = PATH . join2 ( current_path , parts [ i ] ) ;
197205 try {
198206 current = FS . lookupNode ( current , parts [ i ] ) ;
@@ -218,7 +226,10 @@ FS.staticInit();
218226 throw new FS . ErrnoError ( { { { cDefs . ENOSYS } } } ) ;
219227 }
220228 var link = current . node_ops . readlink ( current ) ;
221- path = PATH_FS . resolve ( PATH . dirname ( current_path ) , link , ...parts . slice ( i + 1 ) ) ;
229+ if ( ! PATH . isAbs ( link ) ) {
230+ link = PATH . dirname ( current_path ) + '/' + link ;
231+ }
232+ path = link + '/' + parts . slice ( i + 1 ) . join ( '/' ) ;
222233 continue linkloop ;
223234 }
224235 }
@@ -1045,7 +1056,6 @@ FS.staticInit();
10451056 if ( typeof path = = 'object' ) {
10461057 node = path ;
10471058 } else {
1048- path = PATH . normalize ( path ) ;
10491059 // noent_okay makes it so that if the final component of the path
10501060 // doesn't exist, lookupPath returns `node: undefined`. `path` will be
10511061 // updated to point to the target of all symlinks.
0 commit comments