// part of the URL path, and not indicate the start of a query
// string or fragment.
url := url.URL{Path: name}
- fmt.Fprintf(w, "<a href=\"%s\">%s</a>\n", url.String(), htmlReplacer.Replace(name))
+ fmt.Fprintf(w, "<a href=\"./%s\">%s</a>\n", url.String(), htmlReplacer.Replace(name))
}
fmt.Fprintf(w, "</pre>\n")
}
tests := []struct {
name, escaped string
}{
- {`simple_name`, `<a href="simple_name">simple_name</a>`},
- {`"'<>&`, `<a href="%22%27%3C%3E&">"'<>&</a>`},
- {`?foo=bar#baz`, `<a href="%3Ffoo=bar%23baz">?foo=bar#baz</a>`},
- {`<combo>?foo`, `<a href="%3Ccombo%3E%3Ffoo"><combo>?foo</a>`},
+ {`simple_name`, `<a href="./simple_name">simple_name</a>`},
+ {`"'<>&`, `<a href="./%22%27%3C%3E&">"'<>&</a>`},
+ {`?foo=bar#baz`, `<a href="./%3Ffoo=bar%23baz">?foo=bar#baz</a>`},
+ {`<combo>?foo`, `<a href="./%3Ccombo%3E%3Ffoo"><combo>?foo</a>`},
}
// We put each test file in its own directory in the fakeFS so we can look at it in isolation.
t.Fatalf("read Body: %v", err)
}
s := string(b)
- if !strings.Contains(s, "<a href=\"a\">a</a>\n<a href=\"b\">b</a>") {
+ if !strings.Contains(s, "<a href=\"./a\">a</a>\n<a href=\"./b\">b</a>") {
t.Errorf("output appears to be unsorted:\n%s", s)
}
}