Timo Vetter
1c7dc1820a
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
30 lines
512 B
Go
30 lines
512 B
Go
package langext
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func BuildUrl(url, path string, params *map[string]string) string {
|
|
if path[:1] == "/" && url[len(url)-1:] == "/" {
|
|
url += path[1:]
|
|
} else if path[:1] != "/" && url[len(url)-1:] != "/" {
|
|
url += "/" + path
|
|
} else {
|
|
url += path
|
|
}
|
|
|
|
if params == nil {
|
|
return url
|
|
}
|
|
|
|
for key, value := range *params {
|
|
if strings.Contains(url, "?") {
|
|
url += fmt.Sprintf("&%s=%s", key, value)
|
|
} else {
|
|
url += fmt.Sprintf("?%s=%s", key, value)
|
|
}
|
|
}
|
|
return url
|
|
}
|