From 6f4d6e074a00682668c4bdb253d0c4a2017bcb4b Mon Sep 17 00:00:00 2001 From: Gustavo Maronato Date: Mon, 18 Sep 2023 02:28:48 -0300 Subject: [PATCH] fix debug logging and map urn --- main.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index f19d8fa..860b03b 100644 --- a/main.go +++ b/main.go @@ -43,10 +43,6 @@ func Run() error { cfg := &Config{} - // Create a logger and add it to the context - l := NewLogger(cfg) - ctx = WithLogger(ctx, l) - // Create a new root command subcommands := []*ff.Command{ NewServerCmd(cfg), @@ -74,7 +70,9 @@ func NewServerCmd(cfg *Config) *ff.Command { Usage: "serve [flags]", ShortHelp: "Start the webfinger server", Exec: func(ctx context.Context, args []string) error { - l := LoggerFromContext(ctx) + // Create a logger and add it to the context + l := NewLogger(cfg) + ctx = WithLogger(ctx, l) // Parse the webfinger files fingermap, err := ParseFingerFile(ctx, cfg) @@ -310,11 +308,9 @@ func ParseFingerFile(ctx context.Context, cfg *Config) (WebFingerMap, error) { for field, value := range v { fieldUrn := field - // If the key is not already an URN, try to find it in the URNs file - if _, err := url.Parse(field); err != nil { - if _, ok := urnMap[field]; ok { - fieldUrn = urnMap[field] - } + // If the key is present in the URNs file, use the value + if _, ok := urnMap[field]; ok { + fieldUrn = urnMap[field] } // If the value is a valid URI, add it to the links