update getting hostname logic
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/yauthdev/yauth/server/constants"
|
||||
)
|
||||
@@ -13,7 +13,25 @@ func GetFrontendHost() string {
|
||||
return `localhost`
|
||||
}
|
||||
|
||||
log.Println("hostname", "."+u.Hostname())
|
||||
host := u.Hostname()
|
||||
hostParts := strings.Split(host, ".")
|
||||
hostPartsLen := len(hostParts)
|
||||
|
||||
return "." + u.Hostname()
|
||||
if hostPartsLen == 1 {
|
||||
return host
|
||||
}
|
||||
|
||||
if hostPartsLen == 2 {
|
||||
if hostParts[0] == "www" {
|
||||
return hostParts[1]
|
||||
} else {
|
||||
return host
|
||||
}
|
||||
}
|
||||
|
||||
if hostPartsLen > 2 {
|
||||
return strings.Join(hostParts[hostPartsLen-2:], ".")
|
||||
}
|
||||
|
||||
return host
|
||||
}
|
||||
|
Reference in New Issue
Block a user