Skip to content

Commit

Permalink
handle wildcard domains
Browse files Browse the repository at this point in the history
  • Loading branch information
allnash committed Nov 7, 2024
1 parent 829f979 commit 7ffc9e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fast-server/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ func (s *Server) setupRoutes() {
var matchedDomain config.Domain
var matchedName string
for domainName, domain := range domainMap {
if strings.HasSuffix(host, domainName) {
// Handle wildcard domains
if strings.HasPrefix(domainName, "*.") {
suffix := domainName[1:] // Remove the *
if strings.HasSuffix(host, suffix) {
if len(suffix) > len(matchedName) {
matchedDomain = domain
matchedName = suffix
}
}
} else if strings.HasSuffix(host, domainName) {
// Handle exact domain matches
if len(domainName) > len(matchedName) {
matchedDomain = domain
matchedName = domainName
Expand Down

0 comments on commit 7ffc9e6

Please sign in to comment.