From ab9995350febaaeb183b14283f80e36743b3e738 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Thu, 15 May 2025 17:58:34 +0200 Subject: [PATCH] sanitize external_url, remove trailing slashes --- internal/config/config.go | 2 ++ internal/config/web.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index dedebac..44ef8e4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -190,6 +190,8 @@ func GetConfig() (*Config, error) { return nil, fmt.Errorf("failed to load config from yaml: %w", err) } + cfg.Web.Sanitize() + return cfg, nil } diff --git a/internal/config/web.go b/internal/config/web.go index 1743305..e4d8dd3 100644 --- a/internal/config/web.go +++ b/internal/config/web.go @@ -1,5 +1,7 @@ package config +import "strings" + // WebConfig contains the configuration for the web server. type WebConfig struct { // RequestLogging enables logging of all HTTP requests. @@ -26,3 +28,7 @@ type WebConfig struct { // KeyFile is the path to the TLS certificate key file. KeyFile string `yaml:"key_file"` } + +func (c *WebConfig) Sanitize() { + c.ExternalUrl = strings.TrimRight(c.ExternalUrl, "/") +}