Skip to content

Commit

Permalink
config: trim trailing slashes from externalURL
Browse files Browse the repository at this point in the history
Fixes #1371.
  • Loading branch information
fsouza committed Oct 20, 2023
1 parent 4908cb9 commit f600070
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (c *Config) ToFakeGcsOptions(logger *slog.Logger, scheme string) fakestorag
Host: c.Host,
Port: uint16(port),
PublicHost: c.publicHost,
ExternalURL: c.externalURL,
ExternalURL: strings.TrimRight(c.externalURL, "/"),
AllowedCORSHeaders: c.allowedCORSHeaders,
Writer: &slogWriter{logger: logger, level: slog.LevelInfo},
EventOptions: eventOptions,
Expand Down
21 changes: 21 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,27 @@ func TestToFakeGcsOptions(t *testing.T) {
NoListener: true,
},
},
{
"external-url with trailing slashes",
Config{
backend: "memory",
fsRoot: "/tmp/something",
publicHost: "127.0.0.1.nip.io:8443",
externalURL: "https://myhost.example.com:8443/",
Host: "0.0.0.0",
Port: 443,
Scheme: "https",
},
fakestorage.Options{
StorageRoot: "",
PublicHost: "127.0.0.1.nip.io:8443",
ExternalURL: "https://myhost.example.com:8443",
Host: "0.0.0.0",
Port: 443,
Scheme: "https",
NoListener: true,
},
},
}

for _, test := range tests {
Expand Down

0 comments on commit f600070

Please sign in to comment.