Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit e4dcda9

Browse files
committed
Keep trailing slashes in joined paths
1 parent c2c8c2c commit e4dcda9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

spec/filter-spec.coffee

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ bestMatch = (candidates, query) ->
55
filter(candidates, query, maxResults: 1)[0]
66

77
rootPath = (segments...) ->
8-
root = if process.platform is 'win32' then 'C:\\' else '/'
9-
root + path.join(segments...)
8+
joinedPath = if process.platform is 'win32' then 'C:\\' else '/'
9+
for segment in segments
10+
if segment is path.sep
11+
joinedPath += segment
12+
else
13+
joinedPath = path.join(joinedPath, segment)
14+
joinedPath
1015

1116
describe "filtering", ->
1217
it "returns an array of the most accurate results", ->
@@ -30,6 +35,7 @@ describe "filtering", ->
3035
rootPath('bar', 'foo')
3136
rootPath('foo', 'bar', path.sep, path.sep, path.sep, path.sep, path.sep)
3237
]
38+
console.log candidates[1]
3339
expect(bestMatch(candidates, 'bar')).toBe candidates[1]
3440

3541
candidates = [

0 commit comments

Comments
 (0)