File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -94,13 +94,16 @@ func main() {
94
94
pos := strings .IndexByte (addr , ':' )
95
95
rediraddr := addr [:pos ] + ":" + strconv .Itoa (config .RedirPort ) // it would be silly to optimize this one
96
96
redir := & http.Server {Addr : rediraddr , Handler : http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
97
-
98
97
// redirect to same hostname as in request but different port and probably schema
99
98
uri := "https://"
100
99
if ! config .Ssl {
101
100
uri = "http://"
102
101
}
103
- uri += r .Host [:strings .IndexByte (r .Host , ':' )] + addr [pos :] + "/"
102
+ if cpos := strings .IndexByte (r .Host , ':' ); cpos > 0 {
103
+ uri += r .Host [:strings .IndexByte (r .Host , ':' )] + addr [pos :] + "/"
104
+ } else {
105
+ uri += r .Host + addr [pos :] + "/"
106
+ }
104
107
105
108
http .Redirect (w , r , uri , http .StatusMovedPermanently )
106
109
})}
You can’t perform that action at this time.
0 commit comments