1
0
mirror of https://github.com/muesli/mastotool synced 2024-12-27 18:03:09 +01:00

Automatically prefix 'https' if the protocol is missing from the URL

This commit is contained in:
Christian Muehlhaeuser 2020-10-04 03:19:10 +02:00
parent 3f563e17e6
commit 5b70cc0c1a
No known key found for this signature in database
GPG Key ID: 3CF9FA45CA1EBB7E

View File

@ -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)
}