Skip to content

Commit

Permalink
Fix: Ensure folder names containing dots don't cause a failure (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
silkentrance authored and phated committed Jan 3, 2019
1 parent af80b79 commit da4fd86
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const interpret = require('interpret');
const EXTRE = /^[.]?[^.]+([.].*)$/;

exports.registerFor = function (filepath, cwd) {
var match = EXTRE.exec(filepath);
var match = EXTRE.exec(path.basename(filepath));
if (!match) {
return;
}
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/folder.with.dots/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data:
trueKey: true
falseKey: false
subKey:
subProp: 1
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ describe('registerFor', function () {
rechoir.registerFor('./test/fixtures/test.yaml');
expect(require('./fixtures/test.yaml')).to.deep.equal(expected);
});
it('must not fail on folders with dots', function () {
delete require.extensions['.yml'];
delete require.extensions['.yaml'];
delete require.cache[require.resolve('require-yaml')];
rechoir.registerFor('./test/fixtures/folder.with.dots/test.yaml');
expect(require('./fixtures/folder.with.dots/test.yaml')).to.deep.equal(expected);
});
});

describe('load', function () {
Expand Down

0 comments on commit da4fd86

Please sign in to comment.