Skip to content

Commit b1183c5

Browse files
committed
bugfix
1 parent b3c3c79 commit b1183c5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

proxy.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ func (p *proxy) admin(w http.ResponseWriter, r *http.Request) {
2323
//重置路由表
2424
p.table.DelAll()
2525
data := r.FormValue("data")
26-
arr := strings.Split(data, "\n")
26+
arr := strings.Split(data, "\r\n")
2727
var newArr []string
2828
for _, item := range arr {
29+
fmt.Println(item)
2930
d := strings.Split(item, "=>")
30-
if len(d) < 2 {
31-
continue
32-
}
3331
_, err := url.Parse(d[1])
3432
if err != nil {
33+
fmt.Println(err.Error())
3534
continue
3635
}
3736
newArr = append(newArr, item)
@@ -40,7 +39,7 @@ func (p *proxy) admin(w http.ResponseWriter, r *http.Request) {
4039
}
4140
newData := strings.Join(newArr, "\n")
4241
w.Header().Set("Content-Type", "text/html;charset=utf-8")
43-
w.Write([]byte("<form><center><textarea autofocus name=\"data\" rows=\"30\" cols=\"100\">" + newData + "</textarea><br><input type=\"submit\" value=\"提交\"></center></form>"))
42+
w.Write([]byte("<form method=\"POST\"><center><textarea autofocus name=\"data\" rows=\"30\" cols=\"100\">" + newData + "</textarea><br><input type=\"submit\" value=\"提交\"></center></form>"))
4443
}
4544

4645
func (p *proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)