Skip to content

Commit

Permalink
add disco suffix
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Piplies <[email protected]>
  • Loading branch information
karlpip authored and mebel123 committed Jul 16, 2024
1 parent 85a9cee commit 2890a92
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func getEnvVariable(envKey string, defaultValue string) string {

func EnsureApiVerison() {
Config.Host = strings.TrimSuffix(Config.Host, "/")
if strings.HasSuffix(Config.Host, "/public") {
if strings.HasSuffix(Config.Host, "/public") || strings.HasSuffix(Config.Host, "/disco") {
Config.Host += "/" + DefaultApiVersion
return
}
Expand Down
28 changes: 20 additions & 8 deletions conf/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@ import (
)

func TestEnsureApiVersion(t *testing.T) {
Config.Host = "https://disco-int.app.corpintra.net/api/public/v1/"
Config.Host = "https://disco.test/api/public/v1/"
EnsureApiVerison()
assert.Equal(t, "https://disco-int.app.corpintra.net/api/public/v1", Config.Host)
Config.Host = "https://disco-int.app.corpintra.net/api/public/v1"
assert.Equal(t, "https://disco.test/api/public/v1", Config.Host)
Config.Host = "https://disco.test/api/public/v1"
EnsureApiVerison()
assert.Equal(t, "https://disco-int.app.corpintra.net/api/public/v1", Config.Host)
Config.Host = "https://disco-int.app.corpintra.net/api/public/"
assert.Equal(t, "https://disco.test/api/public/v1", Config.Host)
Config.Host = "https://disco.test/api/public/"
EnsureApiVerison()
assert.Equal(t, "https://disco-int.app.corpintra.net/api/public/v1", Config.Host)
Config.Host = "https://disco-int.app.corpintra.net/api/public/v32"
assert.Equal(t, "https://disco.test/api/public/v1", Config.Host)
Config.Host = "https://disco.test/api/public/v32"
EnsureApiVerison()
assert.Equal(t, "https://disco-int.app.corpintra.net/api/public/v32", Config.Host)
assert.Equal(t, "https://disco.test/api/public/v32", Config.Host)
Config.Host = "https://disco.test/disco"
EnsureApiVerison()
assert.Equal(t, "https://disco.test/disco/v1", Config.Host)
Config.Host = "https://disco.test/disco/v1"
EnsureApiVerison()
assert.Equal(t, "https://disco.test/disco/v1", Config.Host)
Config.Host = "https://disco.test/disco/"
EnsureApiVerison()
assert.Equal(t, "https://disco.test/disco/v1", Config.Host)
Config.Host = "https://disco.test/disco/v32"
EnsureApiVerison()
assert.Equal(t, "https://disco.test/disco/v32", Config.Host)
}

0 comments on commit 2890a92

Please sign in to comment.