@@ -19,9 +19,10 @@ import (
1919// Tries to serve a legacy file if available
2020func ServeLegacy (w http.ResponseWriter , r * http.Request ) {
2121
22+ relPath := filepath .ToSlash (path .Join (r .URL .Host , r .URL .Path ))
2223 // @TODO PERFORM REQUEST MODIFICATION HERE
24+ // parseHtaccessPath(serverSettings.LegacyHTDOCSPath, filepath.Dir(relPath), w, r)
2325
24- relPath := filepath .ToSlash (path .Join (r .URL .Host , r .URL .Path ))
2526 relPathWithQuery := filepath .ToSlash (path .Join (r .URL .Host , r .URL .Path + url .PathEscape ("?" + r .URL .RawQuery )))
2627 hasQuery := r .URL .RawQuery != ""
2728
@@ -274,3 +275,48 @@ func isScriptUrl(u *url.URL) bool {
274275 }
275276 return false
276277}
278+
279+ // func parseHtaccessPath(root string, relPath string, w http.ResponseWriter, r *http.Request) error {
280+ // // Go from top to bottom
281+ // fmt.Printf("[Legacy] Parsing htaccess files for path: %s\n", relPath)
282+ // nextDir := relPath
283+ // for {
284+ // if nextDir == "" {
285+ // return nil
286+ // }
287+ // // Find .htaccess file in next directory
288+ // htaccessPath := path.Join(root, nextDir, ".htaccess")
289+ // fmt.Printf("[Legacy] Looking for htaccess file: %s\n", htaccessPath)
290+ // file, err := os.Open(htaccessPath)
291+ // if err != nil && os.IsNotExist(err) {
292+ // return err
293+ // } else {
294+ // fmt.Printf("[Legacy] Found htaccess file: %s\n", htaccessPath)
295+ // contents, err := io.ReadAll(file)
296+ // if err != nil {
297+ // return err
298+ // }
299+ // ast, err := parser.Parse(string(contents))
300+
301+ // for _, directive := range ast.Dirs {
302+ // switch directive.Name {
303+ // case "RewriteRule":
304+ // // Expect a split of 3
305+ // if len(directive.Params) != 3 {
306+ // return fmt.Errorf("Invalid RewriteRule directive?")
307+ // }
308+ // src := directive.Params[0]
309+ // dest := directive.Params[1]
310+ // flags := directive.Params[2]
311+ // fmt.Printf("[Legacy] RewriteRule: %s -> %s [%s]\n", src.RawString, dest.RawString, flags.RawString)
312+ // src.Capture([]string{path.Join(r.URL.Host, r.URL.Path)})
313+ // fmt.Printf("[Legacy] var: %s\n", src.VariableName)
314+ // fmt.Printf("[Legacy] ass: %s\n", src.AssignValue)
315+ // default:
316+ // }
317+ // }
318+
319+ // }
320+ // nextDir = filepath.Dir(nextDir)
321+ // }
322+ // }
0 commit comments