Skip to content

Commit

Permalink
fix: handle absolute paths correctly
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
citycide committed Jul 4, 2018
1 parent 36a2416 commit 1753cb8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/glob.nim
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ proc `$`* (glob: Glob): string =
## Useful for using ``echo glob`` directly.
glob.pattern

proc maybeJoin (p1, p2: string): string =
if p2.isAbsolute: p2 else: p1 / p2

proc globToRegex* (pattern: string, isDos = isDosDefault): Regex =
## Converts a string glob pattern to a regex pattern.
globToRegexString(pattern, isDos).toPattern
Expand Down Expand Up @@ -287,12 +290,12 @@ iterator walkGlobKinds* (

var base: string
when pattern is Glob:
dir = dir / pattern.base
dir = maybeJoin(dir, pattern.base)
base = pattern.base
matchPattern = pattern.magic
else:
(base, matchPattern) = splitPattern(matchPattern)
dir = dir / base
dir = maybeJoin(dir, base)

if proceed:
let matcher = matchPattern.glob
Expand Down

0 comments on commit 1753cb8

Please sign in to comment.