|
@@ -207,8 +207,14 @@ func (h *ProxyHandler) handleAccessRouting(w http.ResponseWriter, r *http.Reques
|
|
|
// that is redirectable. E.g. a.b.c.example.co.uk will return example.co.uk
|
|
|
func (h *ProxyHandler) getTopLevelRedirectableDomain(unsetSubdomainHost string) (string, error) {
|
|
|
parts := strings.Split(unsetSubdomainHost, ".")
|
|
|
- fmt.Println(parts)
|
|
|
- if len(parts) <= 2 {
|
|
|
+ if len(parts) > 2 {
|
|
|
+ //Cases where strange tld is used like .co.uk or .com.hk
|
|
|
+ _, ok := h.Parent.tldMap[strings.Join(parts[1:], ".")]
|
|
|
+ if ok {
|
|
|
+ //Already topped
|
|
|
+ return "", errors.New("already at top level domain")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
//Already topped
|
|
|
return "", errors.New("already at top level domain")
|
|
|
}
|
|
@@ -220,7 +226,6 @@ func (h *ProxyHandler) getTopLevelRedirectableDomain(unsetSubdomainHost string)
|
|
|
if ok {
|
|
|
//This is tld length
|
|
|
tld := strings.Join(parts[i-1:], ".")
|
|
|
- fmt.Println("Redirecting to: //" + tld)
|
|
|
return "//" + tld, nil
|
|
|
}
|
|
|
}
|