more work on websocket support

This commit is contained in:
Shivaram Lingamneni
2020-05-04 22:29:10 -04:00
parent 25813f6d3a
commit 3dc5c8de78
17 changed files with 830 additions and 444 deletions
+30
View File
@@ -0,0 +1,30 @@
// Copyright (c) 2020 Shivaram Lingamneni <slingamn@cs.stanford.edu>
// released under the MIT license
package utils
import (
"bytes"
"regexp"
"strings"
)
// yet another glob implementation in Go
func CompileGlob(glob string) (result *regexp.Regexp, err error) {
var buf bytes.Buffer
buf.WriteByte('^')
for {
i := strings.IndexByte(glob, '*')
if i == -1 {
buf.WriteString(regexp.QuoteMeta(glob))
break
} else {
buf.WriteString(regexp.QuoteMeta(glob[:i]))
buf.WriteString(".*")
glob = glob[i+1:]
}
}
buf.WriteByte('$')
return regexp.Compile(buf.String())
}