Skip to content

Commit

Permalink
fix: correctly handle patterns in cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
haltcase committed May 22, 2018
1 parent 14407d7 commit ee12839
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/glob.nim
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ proc pathType (path: string): Option[PathComponent] =
discard

proc splitPattern (pattern: string): tuple[base: string, magic: string] =
if not pattern.contains(re"[^\\]\/"):
return ("", pattern)

var head = pattern
var tail: string
while head.hasMagic:
Expand Down
1 change: 1 addition & 0 deletions tests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ suite "globToRegex":
check isEquiv("**", r"^(?:[^\/]*(?:\/|$))*$")
check isEquiv("src/*.nim", r"^src/[^/]*\.nim$")
check isEquiv("src/**/*.nim", r"^src/(?:[^\/]*(?:\/|$))*[^/]*\.nim$")
check isEquiv("*.nim", r"^[^/]*\.nim$")

check isEquiv(r"\{foo*", r"^\{foo[^/]*$")
check isEquiv(r"*\}.html", r"^[^/]*}\.html$")
Expand Down

0 comments on commit ee12839

Please sign in to comment.