diff --git a/data.go b/data.go index aaeeefb..97b59c5 100644 --- a/data.go +++ b/data.go @@ -333,7 +333,7 @@ func NewRequest(r *http.Request, baseURL *url.URL) (*Request, error) { var err error req := &Request{Original: r} - path := r.URL.Path[1:] // strip leading slash + path := r.URL.EscapedPath()[1:] // strip leading slash req.URL, err = parseURL(path) if err != nil || !req.URL.IsAbs() { // first segment should be options diff --git a/data_test.go b/data_test.go index 2062492..035dca6 100644 --- a/data_test.go +++ b/data_test.go @@ -172,6 +172,10 @@ func TestNewRequest(t *testing.T) { "http://localhost/http:///example.com/foo", "http://example.com/foo", emptyOptions, false, }, + { // escaped path + "http://localhost/http://example.com/%2C", + "http://example.com/%2C", emptyOptions, false, + }, } for _, tt := range tests {