Skip to content

Commit 13b12aa

Browse files
committed
remove trailing slash
1 parent b9401b3 commit 13b12aa

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "firelord",
3-
"version": "2.8.10",
3+
"version": "2.8.15",
44
"description": "🔥 Write V9 like Firestore Admin code with extreme type safety.",
55
"author": "tylim",
66
"license": "MIT",

src/refs/utils.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ describe('test utils', () => {
1414
collectionIDs: ['1', '2', '3'],
1515
documentIDs: ['a', 'b', 'c'],
1616
})
17-
).toBe('1/a/2/b/3/c/')
17+
).toBe('1/a/2/b/3/c')
1818

1919
expect(
2020
buildPathFromColIDsAndDocIDs({
2121
collectionIDs: ['1', '2', '3'],
2222
documentIDs: ['a', 'b'],
2323
})
24-
).toBe('1/a/2/b/3/')
24+
).toBe('1/a/2/b/3')
2525

2626
expect(
2727
buildPathFromColIDsAndDocIDs({
2828
collectionIDs: ['1', '2'],
2929
documentIDs: ['a', 'b', 'c'],
3030
})
31-
).toBe('1/a/2/b/')
31+
).toBe('1/a/2/b')
3232

3333
expect(
3434
buildPathFromColIDsAndDocIDs({
@@ -42,6 +42,6 @@ describe('test utils', () => {
4242
collectionIDs: ['1', '2'],
4343
documentIDs: [],
4444
})
45-
).toBe('1/2/')
45+
).toBe('1/2')
4646
})
4747
})

src/refs/utils.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ export const buildPathFromColIDsAndDocIDs = ({
1313
collectionIDs: string[]
1414
documentIDs: string[]
1515
}) => {
16-
return collectionIDs.reduce((acc, collectionId, index) => {
17-
const documentID = documentIDs[index] ? `${documentIDs[index]}/` : ''
18-
return `${acc}${collectionId}/${documentID}`
19-
}, '')
16+
return collectionIDs
17+
.reduce((acc, collectionId, index) => {
18+
const documentID = documentIDs[index] ? `${documentIDs[index]}/` : ''
19+
return `${acc}${collectionId}/${documentID}`
20+
}, '')
21+
.slice(0, -1)
2022
}

0 commit comments

Comments
 (0)