Skip to content

Commit

Permalink
Removes double slashes, fixes #78
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Aug 20, 2019
1 parent 32b5b57 commit 440029a
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 8 deletions.
9 changes: 8 additions & 1 deletion dist/indian-ocean.browser.es6.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/indian-ocean.browser.es6.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/indian-ocean.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/indian-ocean.cjs.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/indian-ocean.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/indian-ocean.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/indian-ocean.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/utils/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ export function dirname (path) {
return dir || '/'
}

/* --------------------------------------------
* Join a path with a slash, removing any stub entries that end in a slash
* to avoid a double slash scenario
*/
export function joinPath () {
var args = Array.prototype.slice.call(arguments)
return args.join('/') // TODO, windows
return args.map((d, i) => {
if (i === args.length - 1) return d
return d.replace(/\/$/, '')
}).join('/') // TODO, windows
}
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,13 @@ describe('readers', function () {
done(assert.notEqual(files.indexOf(path.join(dir, 'this_is_not_a_csv.txt')), -1))
})
})
it('should match expected output stripping trailing slash', function (done) {
var dir = path.join(__dirname, 'data', 'other/')
io.readdirFilter(dir, {exclude: 'csv', fullPath: true}, function (err, files) {
assert.equal(err, null)
done(assert.notEqual(files.indexOf(path.join(dir, 'this_is_not_a_csv.txt')), -1))
})
})
})

describe('get dirs only', function () {
Expand Down Expand Up @@ -1714,6 +1721,11 @@ describe('readers', function () {
var files = io.readdirFilterSync(dir, {include: 'csv', fullPath: true})
assert.equal(files.indexOf(path.join(dir, 'basic.csv')), 0)
})
it('should match expected output with trailing slash', function () {
var dir = path.join(__dirname, 'data', 'csv/')
var files = io.readdirFilterSync(dir, {include: 'csv', fullPath: true})
assert.equal(files.indexOf(path.join(dir, 'basic.csv')), 0)
})
})

describe('detailed readdir results', function () {
Expand Down

0 comments on commit 440029a

Please sign in to comment.