Skip to content

Commit

Permalink
Prefer scheme on child route when building URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHines authored and kisielk committed Jul 4, 2017
1 parent 37b3a6c commit ac112f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,17 @@ func TestSubRouter(t *testing.T) {
hostTemplate: `google.com`,
shouldMatch: true,
},
{
title: "Prefer scheme on child route when building URLs",
route: new(Route).Schemes("https", "ftp").Host("google.com").Subrouter().Schemes("ftp").Path("/"),
request: newRequest("GET", "ftp://google.com/"),
scheme: "ftp",
host: "google.com",
path: "/",
pathTemplate: `/`,
hostTemplate: `google.com`,
shouldMatch: true,
},
}

for _, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion route.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (r *Route) Schemes(schemes ...string) *Route {
for k, v := range schemes {
schemes[k] = strings.ToLower(v)
}
if r.getBuildScheme() == "" && len(schemes) > 0 {
if r.buildScheme == "" && len(schemes) > 0 {
r.buildScheme = schemes[0]
}
return r.addMatcher(schemeMatcher(schemes))
Expand Down

0 comments on commit ac112f7

Please sign in to comment.