Skip to content
Browse files

minor

  • Loading branch information...
1 parent b4bc30c commit bf41f677d0603ee3836c2547b48d5c8d5397caba @eldargab committed
Showing with 6 additions and 10 deletions.
  1. +6 −10 lib/fake-fs.js
View
16 lib/fake-fs.js
@@ -31,11 +31,9 @@ Fs.prototype.file = function (path, content, encoding) {
}
Fs.prototype._add = function (path, item) {
- var segs = path.split('/'); segs.shift()
-
- if (segs[segs.length - 1] === "") {
- segs.pop();
- }
+ var segs = path == '/'
+ ? []
+ : path.split('/').slice(1)
var dir = this.root
for (var i = 0; i < segs.length - 1; i++) {
@@ -49,11 +47,9 @@ Fs.prototype._add = function (path, item) {
}
Fs.prototype._itemAt = function (path) {
- var segs = resolve(path).split('/'); segs.shift()
-
- if (segs[segs.length - 1] === "") {
- segs.pop();
- }
+ var segs = path == '/'
+ ? []
+ : resolve(path).split('/').slice(1)
var item = this.root
for (var i = 0; i < segs.length; i++) {

0 comments on commit bf41f67

Please sign in to comment.
Something went wrong with that request. Please try again.