Skip to content

Commit 0c076d1

Browse files
authored
Merge pull request #14 from timbeadle/bug/dynamic-concat-path
Bug/dynamic concat path
2 parents e8c099a + 44d5d47 commit 0c076d1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/cfpathcheck.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,20 @@ function checkFile(filePath) {
211211
var cfIncludeMatches = matchAll(line, /template=\"([^"]+)\"/g);
212212

213213
// include '$path'; (inside <cfscript>)
214-
var includeMatches = matchAll(line, /\binclude\s['"]([^'"]+)['"]/g);
214+
var includeMatches = matchAll(line, /\binclude\s['"](.*\.cfm)['"]/g);
215215

216216
cfIncludeMatches.concat(includeMatches).forEach(function (includeMatch) {
217217
// console.log(includeMatch);
218218

219-
// Dynamic path (contains #): all we can check is the non-dynamic part
219+
// Dynamic path (contains # or &): all we can check is the non-dynamic part,
220+
// wound back to the last slash
220221
var templatePath = includeMatch[1];
221222
var hashPos = templatePath.indexOf('#');
222-
if (hashPos !== -1) {
223-
templatePath = path.dirname(templatePath.substr(0, hashPos));
223+
var ampersandPos = templatePath.indexOf('&');
224+
if (hashPos !== -1 || ampersandPos !== -1) {
225+
var searchPos = hashPos !== -1 ? hashPos : ampersandPos;
226+
var lastSlashPos = templatePath.lastIndexOf('/', searchPos);
227+
templatePath = path.dirname(templatePath.substr(0, lastSlashPos));
224228
}
225229

226230
// Can't work with webroot-virtual paths, e.g. /missing.cfm

0 commit comments

Comments
 (0)