Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"fmt"
"github.com/justintan/gox"
"github.com/justintan/wine"
"time"
"github.com/shanks-hongfa/wine"
)

func main() {
Expand Down
14 changes: 13 additions & 1 deletion path.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package wine

import "strings"
import (
"strings"
"regexp"
)

func cleanPath(path string) string {
if path == "" {
Expand All @@ -24,3 +27,12 @@ func cleanPath(path string) string {

return path
}

//过滤`//`
func filterSlashPath(path string) string{
if path == ""{
return "/"
}
re, _ := regexp.Compile("/{2,}")
return re.ReplaceAllString(path,"/")
}
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (this *server) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if i > 0 {
path = req.RequestURI[:i]
}
path=cleanPath(path)
path=filterSlashPath(path)
handlers, params := this.Match(req.Method, path)
if len(handlers) == 0 {
gox.LError("Not found", path, "[", req.RequestURI, "]")
Expand Down