File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ func removeDotSegments(u *url.URL) {
231231 }
232232 // Special case if host does not end with / and new path does not begin with /
233233 u .Path = strings .Join (dotFree , "/" )
234- if ! strings .HasSuffix (u .Host , "/" ) && ! strings .HasPrefix (u .Path , "/" ) {
234+ if u . Host != "" && ! strings .HasSuffix (u .Host , "/" ) && ! strings .HasPrefix (u .Path , "/" ) {
235235 u .Path = "/" + u .Path
236236 }
237237 // Special case if the last segment was a dot, make sure the path ends with a slash
Original file line number Diff line number Diff line change @@ -653,6 +653,28 @@ var (
653653 "http://test.example/foo/bar/" ,
654654 false ,
655655 },
656+ & testCase {
657+ "Relative-1" ,
658+ "./../foo" ,
659+ FlagsSafe | FlagRemoveDotSegments | FlagRemoveDuplicateSlashes ,
660+ "foo" ,
661+ false ,
662+ },
663+ & testCase {
664+ "Relative-2" ,
665+ "./foo/bar/../baz/../bang/.." ,
666+ FlagsSafe | FlagRemoveDotSegments | FlagRemoveDuplicateSlashes ,
667+ "foo/" ,
668+ false ,
669+ },
670+ & testCase {
671+ "Relative-3" ,
672+ "foo///bar//" ,
673+ FlagsSafe | FlagRemoveDotSegments | FlagRemoveDuplicateSlashes ,
674+ "foo/bar/" ,
675+ false ,
676+ },
677+
656678 /*&testCase{
657679 "UrlNorm-5",
658680 "http://ja.wikipedia.org/wiki/%E3%82%AD%E3%83%A3%E3%82%BF%E3%83%94%E3%83%A9%E3%83%BC%E3%82%B8%E3%83%A3%E3%83%91%E3%83%B3",
You can’t perform that action at this time.
0 commit comments