From 37c9f4d6ab66abcefeea57cbb00167ff402ac440 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Thu, 5 Oct 2017 17:57:41 +0000 Subject: [PATCH] preserve original URL encoding fixes #115 --- data.go | 2 +- data_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 {