diff options
-rw-r--r-- | dynamic.go | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -35,16 +35,18 @@ func handle(w http.ResponseWriter, r *http.Request) { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | // get the list of dirs to parse | 37 | // get the list of dirs to parse |
38 | request := strings.Trim(r.URL.Path, "/") | 38 | request := strings.TrimSuffix(r.URL.Path, "/") |
39 | dirs := strings.Split(request, "/") | 39 | dirs := strings.Split(request, "/") |
40 | if request != "" { | 40 | for i, dir := range dirs { |
41 | dirs = append(dirs, "") | 41 | if i != 0 { |
42 | dirs[i] = path.Join(dirs[i-1], dir) | ||
43 | } | ||
42 | } | 44 | } |
43 | 45 | ||
44 | // parse these dirs | 46 | // parse these dirs |
45 | elements := make(map[string][]byte) | 47 | elements := make(map[string][]byte) |
46 | for _, dir := range dirs { | 48 | for i := len(dirs) - 1; i >= 0; i-- /*_, dir := range reverse dirs*/ { |
47 | parse(path.Join(*settings.sourceDir, dir), elements, settings.exts, false) | 49 | parse(path.Join(*settings.sourceDir, dirs[i]), elements, settings.exts, false) |
48 | } | 50 | } |
49 | 51 | ||
50 | // render the page | 52 | // render the page |