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() {
9494 pos := strings .IndexByte (addr , ':' )
9595 rediraddr := addr [:pos ] + ":" + strconv .Itoa (config .RedirPort ) // it would be silly to optimize this one
9696 redir := & http.Server {Addr : rediraddr , Handler : http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
97-
9897 // redirect to same hostname as in request but different port and probably schema
9998 uri := "https://"
10099 if ! config .Ssl {
101100 uri = "http://"
102101 }
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+ }
104107
105108 http .Redirect (w , r , uri , http .StatusMovedPermanently )
106109 })}
You can’t perform that action at this time.
0 commit comments