build 4
This commit is contained in:
12
main.go
12
main.go
@@ -21,10 +21,8 @@ const (
|
||||
|
||||
func checkUrl(u string) bool {
|
||||
for _, exp := range []string{exp1, exp2, exp3, exp4, exp5, exp6} {
|
||||
if ok, e := regexp.MatchString(exp, u); ok {
|
||||
if ok, _ := regexp.MatchString(exp, u); ok {
|
||||
return true
|
||||
} else if e != nil {
|
||||
fmt.Println(e)
|
||||
}
|
||||
}
|
||||
return false
|
||||
@@ -50,15 +48,15 @@ func fetchHandler(w http.ResponseWriter, r *http.Request) {
|
||||
match6, _ := regexp.MatchString(exp6, u.String())
|
||||
|
||||
if match1 || match5 || match6 || match3 || match4 {
|
||||
httpHandler(w, r, path)
|
||||
httpHandler(w, r, u.String())
|
||||
return
|
||||
} else if match2 {
|
||||
path = strings.ReplaceAll(u.Path, "/blob/", "/raw/")
|
||||
httpHandler(w, r, path)
|
||||
u.Path = strings.ReplaceAll(u.Path, "/blob/", "/raw/")
|
||||
httpHandler(w, r, u.String())
|
||||
return
|
||||
}
|
||||
|
||||
http.Error(w, fmt.Sprintf("%s is not support", path), http.StatusOK)
|
||||
http.Error(w, fmt.Sprintf("%s is not support", u.String()), http.StatusOK)
|
||||
}
|
||||
|
||||
func httpHandler(w http.ResponseWriter, r *http.Request, pathname string) {
|
||||
|
||||
Reference in New Issue
Block a user