fix: one decoded path form for crawl keys and CMS lookups
Crawl keys, the rendered comparison and the link graph use the decoded path (classes.PathKey), the form the resolver, the descriptors and the SEO entries use; the request URL is percent-encoded again (classes.EscapeKeyPath). A non-ASCII address now matches its CMS record and its stored links. A path that does not decode to text keeps its encoded form.
This commit is contained in:
@@ -41,6 +41,32 @@ func TestFetcherPortAndKey(t *testing.T) {
|
||||
t.Errorf("Allowed(%s) = %v", raw, f.Allowed(u))
|
||||
}
|
||||
}
|
||||
// One decoded path form (WR-04, P33-61): the key is decoded, the
|
||||
// request URL encoded; a path that does not decode to text keeps its
|
||||
// encoded form, and so does one holding "%" or "?".
|
||||
for raw, want := range map[string]string{
|
||||
"https://site.test/blog/za%C5%BC%C3%B3%C5%82%C4%87?a=1": "/blog/zażółć?a=1",
|
||||
"https://site.test/blog/zażółć": "/blog/zażółć",
|
||||
"https://site.test/%FF": "/%FF",
|
||||
"https://site.test/a%00b": "/a%00b",
|
||||
"https://site.test/100%25": "/100%25",
|
||||
"https://site.test/a%3Fb?c=1": "/a%3Fb?c=1",
|
||||
} {
|
||||
if got := f.Key(parse(raw)); got != want {
|
||||
t.Errorf("Key(%s) = %q, want %q", raw, got, want)
|
||||
}
|
||||
}
|
||||
for key, want := range map[string]string{
|
||||
"/blog/zażółć?a=1": "https://site.test/blog/za%C5%BC%C3%B3%C5%82%C4%87?a=1",
|
||||
"/%FF": "https://site.test/%FF",
|
||||
"/100%25": "https://site.test/100%25",
|
||||
"/a b": "https://site.test/a%20b",
|
||||
"/": "https://site.test/",
|
||||
} {
|
||||
if got := f.Absolute(key); got != want {
|
||||
t.Errorf("Absolute(%q) = %q, want %q", key, got, want)
|
||||
}
|
||||
}
|
||||
local, err := NewFetcher("http://localhost:3000", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user