Prevent accidental file matching when glob contains trailing slash (#805)

* Draft Solution

* Update internal-globber.ts

* Cleanup

* Fix Test

* Cleanup
This commit is contained in:
Luke Tomlinson
2021-05-14 14:12:26 -04:00
committed by GitHub
parent b33912b7cc
commit 98549fbf21
4 changed files with 43 additions and 6 deletions

View File

@@ -97,6 +97,24 @@ describe('globber', () => {
])
})
it('does not match file with trailing slash when implicitDescendants=true', async () => {
// Create the following layout:
// <root>
// <root>/file
const root = path.join(
getTestTemp(),
'defaults-to-implicit-descendants-true'
)
const filePath = path.join(root, 'file')
await fs.mkdir(root, {recursive: true})
await fs.writeFile(filePath, 'test file content')
const itemPaths = await glob(`${filePath}/`, {})
expect(itemPaths).toEqual([])
})
it('defaults to omitBrokenSymbolicLinks=true', async () => {
// Create the following layout:
// <root>