Skip to content

Commit

Permalink
Automatically prefix 'https' if the protocol is missing from the URL
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Oct 4, 2020
1 parent 3f563e1 commit 5b70cc0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"os"
"strings"

mastodon "github.com/mattn/go-mastodon"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 5b70cc0

Please sign in to comment.