// lookup looks for the *Directory for a given path, relative to dir.
func (dir *Directory) lookup(path string) *Directory {
- d := strings.Split(dir.Path, "/", -1)
- p := strings.Split(path, "/", -1)
+ d := strings.Split(dir.Path, string(filepath.Separator), -1)
+ p := strings.Split(path, string(filepath.Separator), -1)
i := 0
for i < len(d) {
if i >= len(p) || d[i] != p[i] {
if strings.HasPrefix(d.Path, root.Path) {
path = d.Path[len(root.Path):]
}
- // remove trailing '/' if any - path must be relative
- if len(path) > 0 && path[0] == '/' {
+ // remove trailing separator if any - path must be relative
+ if len(path) > 0 && filepath.IsAbs(path) {
path = path[1:]
}
p.Path = path
flag.Usage = usage
flag.Parse()
+ // Clean goroot: normalize path separator.
+ *goroot = filepath.Clean(*goroot)
+
// Check usage: either server and no args, or command line and args
if (*httpAddr != "") != (flag.NArg() == 0) {
usage()