diff --git a/src/utilities/readDirectory.js b/src/utilities/readDirectory.js index f7a7e09..1fa333d 100644 --- a/src/utilities/readDirectory.js +++ b/src/utilities/readDirectory.js @@ -17,7 +17,7 @@ const hasMultipleExtensions = (fileName) => { }; const isSafeName = (fileName) => { - return /^[a-z][a-z0-9._]+$/i.test(fileName); + return /^[a-z_][a-z0-9._]*$/i.test(fileName); }; const stripExtension = (fileName) => { diff --git a/test/fixtures/read-directory/children-directories-short-name/F/index.js b/test/fixtures/read-directory/children-directories-short-name/F/index.js new file mode 100644 index 0000000..b83b7f9 --- /dev/null +++ b/test/fixtures/read-directory/children-directories-short-name/F/index.js @@ -0,0 +1 @@ +// @create-index diff --git a/test/fixtures/read-directory/children-directories-short-name/T/index.js b/test/fixtures/read-directory/children-directories-short-name/T/index.js new file mode 100644 index 0000000..b83b7f9 --- /dev/null +++ b/test/fixtures/read-directory/children-directories-short-name/T/index.js @@ -0,0 +1 @@ +// @create-index diff --git a/test/fixtures/read-directory/children-directories-short-name/__/index.js b/test/fixtures/read-directory/children-directories-short-name/__/index.js new file mode 100644 index 0000000..b83b7f9 --- /dev/null +++ b/test/fixtures/read-directory/children-directories-short-name/__/index.js @@ -0,0 +1 @@ +// @create-index diff --git a/test/fixtures/read-directory/children-directories-short-name/o/index.js b/test/fixtures/read-directory/children-directories-short-name/o/index.js new file mode 100644 index 0000000..b83b7f9 --- /dev/null +++ b/test/fixtures/read-directory/children-directories-short-name/o/index.js @@ -0,0 +1 @@ +// @create-index diff --git a/test/readDirectory.js b/test/readDirectory.js index 31ea9be..90c1fd0 100644 --- a/test/readDirectory.js +++ b/test/readDirectory.js @@ -21,6 +21,13 @@ describe('readDirectory()', () => { expect(names).to.deep.equal(['present.js']); }); }); + context('target directory contains child directories (short safe name)', () => { + it('gets names of the children directories', () => { + const names = readDirectory(path.resolve(fixturesPath, 'children-directories-short-name')); + + expect(names).to.deep.equal(['F', 'T', '__', 'o']); + }); + }); context('target directory contains child directories (unsafe name)', () => { it('gets names of the children directories', () => { const names = readDirectory(path.resolve(fixturesPath, 'children-directories-unsafe-name'));