From 5b70cc0c1a2953830dc8c2e1f384fd91d6ba9d43 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 4 Oct 2020 03:19:10 +0200 Subject: [PATCH] Automatically prefix 'https' if the protocol is missing from the URL --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 3384c87..18867c6 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "context" "fmt" "os" + "strings" mastodon "github.com/mattn/go-mastodon" "github.com/spf13/cobra" @@ -65,7 +66,12 @@ func initClient() error { if scanner.Err() != nil { return fmt.Errorf("Can't open input: %s", err) } + instance = scanner.Text() + if !strings.HasPrefix(instance, "http") { + instance = "https://" + instance + } + config.Set("instance", instance) }