@@ -10,7 +10,6 @@ import (
10
10
"net/http"
11
11
"path"
12
12
"regexp"
13
- "strings"
14
13
)
15
14
16
15
var (
@@ -94,7 +93,7 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
94
93
if ! r .skipClean {
95
94
path := req .URL .Path
96
95
if r .useEncodedPath {
97
- path = getPath ( req )
96
+ path = req . URL . EscapedPath ( )
98
97
}
99
98
// Clean path to canonical form and redirect.
100
99
if p := cleanPath (path ); p != path {
@@ -409,28 +408,6 @@ func setCurrentRoute(r *http.Request, val interface{}) *http.Request {
409
408
// Helpers
410
409
// ----------------------------------------------------------------------------
411
410
412
- // getPath returns the escaped path if possible; doing what URL.EscapedPath()
413
- // which was added in go1.5 does
414
- func getPath (req * http.Request ) string {
415
- if req .RequestURI != "" {
416
- // Extract the path from RequestURI (which is escaped unlike URL.Path)
417
- // as detailed here as detailed in https://golang.org/pkg/net/url/#URL
418
- // for < 1.5 server side workaround
419
- // http://localhost/path/here?v=1 -> /path/here
420
- path := req .RequestURI
421
- path = strings .TrimPrefix (path , req .URL .Scheme + `://` )
422
- path = strings .TrimPrefix (path , req .URL .Host )
423
- if i := strings .LastIndex (path , "?" ); i > - 1 {
424
- path = path [:i ]
425
- }
426
- if i := strings .LastIndex (path , "#" ); i > - 1 {
427
- path = path [:i ]
428
- }
429
- return path
430
- }
431
- return req .URL .Path
432
- }
433
-
434
411
// cleanPath returns the canonical path for p, eliminating . and .. elements.
435
412
// Borrowed from the net/http package.
436
413
func cleanPath (p string ) string {
0 commit comments