refactor/handlers (#51)

* wip

* refactor: use prefix instead of patern in docker meta

* tests: fix tests
This commit is contained in:
Stavros
2025-03-19 15:48:16 +02:00
committed by GitHub
parent 52f189563b
commit f3471880ee
8 changed files with 811 additions and 704 deletions

View File

@@ -46,14 +46,14 @@ func ParseUsers(users string) (types.Users, error) {
return usersParsed, nil
}
// Root url parses parses a hostname and returns the root domain (e.g. sub1.sub2.domain.com -> sub2.domain.com)
func GetRootURL(urlSrc string) (string, error) {
// Get upper domain parses a hostname and returns the upper domain (e.g. sub1.sub2.domain.com -> sub2.domain.com)
func GetUpperDomain(urlSrc string) (string, error) {
// Make sure the url is valid
urlParsed, parseErr := url.Parse(urlSrc)
urlParsed, err := url.Parse(urlSrc)
// Check if there was an error
if parseErr != nil {
return "", parseErr
if err != nil {
return "", err
}
// Split the hostname by period

View File

@@ -38,15 +38,15 @@ func TestParseUsers(t *testing.T) {
}
}
// Test the get root url function
func TestGetRootURL(t *testing.T) {
t.Log("Testing get root url with a valid url")
// Test the get upper domain function
func TestGetUpperDomain(t *testing.T) {
t.Log("Testing get upper domain with a valid url")
// Test the get root url function with a valid url
// Test the get upper domain function with a valid url
url := "https://sub1.sub2.domain.com:8080"
expected := "sub2.domain.com"
result, err := utils.GetRootURL(url)
result, err := utils.GetUpperDomain(url)
// Check if there was an error
if err != nil {