Permalink
Browse files

Merge pull request #298 from prose/file-match

file path filter tweaks, fixes #254
  • Loading branch information...
2 parents 3cf3be8 + 8e046ad commit 9f30b3c2652a8177969ca6c7202ef07ffc788415 @dhcole dhcole committed Mar 27, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 _includes/model.js
View
@@ -164,7 +164,7 @@ function getFiles(tree, path, searchstr) {
var pathMatches = 0;
function matchesPath(file) {
if (file.path === path) return false; // skip current path
- var match = file.path.match(new RegExp("^"+path+"(.*)$"));
+ var match = file.path.match(new RegExp("^"+path+"/(.*)$"));
if (match) {
return !!searchstr || match[1].split('/').length <= (path ? 2 : 1);
}
@@ -187,8 +187,10 @@ function getFiles(tree, path, searchstr) {
// Scope name to current path
file.name = file.name.replace(new RegExp("^"+path+"/?"), "");
- // Mark match
- file.name = file.name.replace(matchSearch, "<b>$1</b>");
+ // Mark match if searchstr not empty
+ if (searchstr.length) {
+ file.name = file.name.replace(matchSearch, "<b>$1</b>");
+ }
if (!matchesPath(file)) return false;
pathMatches += 1;

0 comments on commit 9f30b3c

Please sign in to comment.