Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func (ub *urlBuilder) URL() (u *url.URL, err error) {
)
u.Host = cmp.Or(ub.host, u.Host)
for _, p := range ub.paths {
u.Path = u.ResolveReference(&url.URL{Path: p}).Path
resolved := u.ResolveReference(&url.URL{Path: p})
u.Path, u.RawPath = resolved.Path, resolved.RawPath
}
if len(ub.params) > 0 {
q := u.Query()
Expand Down
10 changes: 10 additions & 0 deletions core_url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ var PathCases = map[string]struct {
[]string{"b/", "c/", "/d"},
"https://example/d",
},
"escaped-base-segment": {
"https://example/a%2Fb/",
[]string{"c"},
"https://example/a%2Fb/c",
},
"escaped-base-parent": {
"https://example/a%2Fb/c/",
[]string{"../d"},
"https://example/a%2Fb/d",
},
}

func TestCorePath(t *testing.T) {
Expand Down