Skip to content

Commit 66bad8b

Browse files
committed
cmd: fix --match for Windows, fixes #901
1 parent 8cf9eb3 commit 66bad8b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/minify/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,18 @@ func minifyWorker(chanTasks <-chan Task, chanFails chan<- int) {
624624
// compilePattern returns *regexp.Regexp or glob.Glob
625625
func compilePattern(pattern string) (*regexp.Regexp, error) {
626626
if len(pattern) == 0 || pattern[0] != '~' {
627+
sep := string(filepath.Separator)
628+
if sep == `\` {
629+
sep = `\\`
630+
}
631+
627632
if strings.HasPrefix(pattern, `\~`) {
628633
pattern = pattern[1:]
629634
}
630635
pattern = regexp.QuoteMeta(pattern)
631636
pattern = strings.ReplaceAll(pattern, `\*\*`, `.*`)
632-
pattern = strings.ReplaceAll(pattern, `\*`, fmt.Sprintf(`[^%c]*`, filepath.Separator))
633-
pattern = strings.ReplaceAll(pattern, `\?`, fmt.Sprintf(`[^%c]?`, filepath.Separator))
637+
pattern = strings.ReplaceAll(pattern, `\*`, fmt.Sprintf(`[^%s]*`, sep))
638+
pattern = strings.ReplaceAll(pattern, `\?`, fmt.Sprintf(`[^%s]?`, sep))
634639
pattern = "^" + pattern + "$"
635640
}
636641
return regexp.Compile(pattern)

0 commit comments

Comments
 (0)