diff options
author | Wolfy-J <[email protected]> | 2018-06-12 18:30:54 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-12 18:30:54 +0300 |
commit | 9980f8a1a4f8c2aebd8e40a8e892bda4bf734eb0 (patch) | |
tree | 6c6956e96498b8ba0fe78014117ee15fcbf5db07 /service/http/parse.go | |
parent | 592bda7d2b2c58ce466979e567158202f07bda7e (diff) |
tests!
Diffstat (limited to 'service/http/parse.go')
-rw-r--r-- | service/http/parse.go | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/service/http/parse.go b/service/http/parse.go index 3b084eb8..96ffcdcc 100644 --- a/service/http/parse.go +++ b/service/http/parse.go @@ -1,10 +1,8 @@ package http import ( - "strings" "net/http" "os" - "log" ) // MaxLevel defines maximum tree depth for incoming request data and files. @@ -38,11 +36,7 @@ func (d dataTree) push(k string, v []string) { return } - indexes := make([]string, 0) - for _, index := range strings.Split(strings.Replace(k, "]", "", MaxLevel), "[") { - indexes = append(indexes, index) - } - + indexes := fetchIndexes(k) if len(indexes) <= MaxLevel { d.mount(indexes, v) } @@ -50,8 +44,6 @@ func (d dataTree) push(k string, v []string) { // mount mounts data tree recursively. func (d dataTree) mount(i []string, v []string) { - log.Println(i, ">", v) - if len(v) == 0 { return } @@ -70,6 +62,7 @@ func (d dataTree) mount(i []string, v []string) { if p, ok := d[i[0]]; ok { p.(dataTree).mount(i[1:], v) + return } d[i[0]] = make(dataTree) @@ -118,11 +111,7 @@ func (d fileTree) push(k string, v []*FileUpload) { return } - indexes := make([]string, 0) - for _, index := range strings.Split(k, "[") { - indexes = append(indexes, strings.Trim(index, "]")) - } - + indexes := fetchIndexes(k) if len(indexes) <= MaxLevel { d.mount(indexes, v) } @@ -148,6 +137,7 @@ func (d fileTree) mount(i []string, v []*FileUpload) { if p, ok := d[i[0]]; ok { p.(fileTree).mount(i[1:], v) + return } d[i[0]] = make(fileTree) @@ -177,7 +167,7 @@ func fetchIndexes(s string) []string { } pos = 2 default: - if pos > 0 { + if pos == 1 || pos == 2 { keys = append(keys, "") } |