mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
9f85b74fc9
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
30 lines
717 B
Go
30 lines
717 B
Go
package router
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSplitSubdomainAndPath(t *testing.T) {
|
|
tests := []struct {
|
|
original string
|
|
subdomain string
|
|
path string
|
|
}{
|
|
{"admin./users/42", "admin.", "/users/42"},
|
|
{"//api/users\\42", "", "/api/users/42"},
|
|
{"admin./users/\\42", "admin.", "/users/42"},
|
|
{"*./users/\\42", "*.", "/users/42"},
|
|
}
|
|
|
|
for i, tt := range tests {
|
|
subdomain, path := splitSubdomainAndPath(tt.original)
|
|
|
|
if expected, got := tt.subdomain, subdomain; expected != got {
|
|
t.Fatalf("[%d] - expected subdomain '%s' but got '%s'", i, expected, got)
|
|
}
|
|
if expected, got := tt.path, path; expected != got {
|
|
t.Fatalf("[%d] - expected path '%s' but got '%s'", i, expected, got)
|
|
}
|
|
}
|
|
}
|