diff --git a/lib/revvedfinder.js b/lib/revvedfinder.js index 29e33e1..6eff823 100644 --- a/lib/revvedfinder.js +++ b/lib/revvedfinder.js @@ -50,18 +50,19 @@ RevvedFinder.prototype.getCandidatesFromMapping = function (file, searchPaths) { RevvedFinder.prototype.getCandidatesFromFS = function (file, searchPaths) { var extname = path.extname(file); + var regExtname = extname || '.'; var basename = path.basename(file, extname); var dirname = path.dirname(file); var hex = '[0-9a-fA-F]+'; var regPrefix = '(' + hex + '\\.' + regexpQuote(basename) + ')'; - var regSuffix = '(' + regexpQuote(basename) + '\\.' + hex + regexpQuote(extname) + ')'; + var regSuffix = '(' + regexpQuote(basename) + '\\.' + hex + regexpQuote(regExtname) + ')'; var revvedRx = new RegExp(regPrefix + '|' + regSuffix); var candidates = []; var self = this; searchPaths.forEach(function (sp) { - var searchString = path.join(sp, dirname, basename + '.*' + extname); - var prefixSearchString = path.join(sp, dirname, '*.' + basename + extname); + var searchString = path.join(sp, dirname, basename + '.*' + regExtname); + var prefixSearchString = path.join(sp, dirname, '*.' + basename + regExtname); if (searchString.indexOf('#') === 0) { // patterns starting with # are treated as comments by the glob implementation which returns undefined, diff --git a/test/test-revvedfinder.js b/test/test-revvedfinder.js index 5977b88..2a5b6c6 100644 --- a/test/test-revvedfinder.js +++ b/test/test-revvedfinder.js @@ -143,6 +143,14 @@ describe('RevvedFinder', function () { assert.equal(rfile, 'fred.html'); }); + it('should support extensionless paths', function () { + var rf = new RevvedFinder(function () { + return ['path.css']; + }); + var rfile = rf.find('path', '.'); + assert.equal(rfile, 'path'); + }); + // it('should restrict to the furnished subdirectories', function () { // var rf = new RevvedFinder(function (pattern) { // assert.equal(pattern, '{temp,dist}/**/*fred\\.html');