1
0
mirror of https://github.com/writeas/writeas-cli synced 2025-07-26 23:08:16 +00:00

fix post url for non standard hostnames

This commit is contained in:
Rob Loranger 2019-09-10 10:59:36 -07:00
parent b60ae1edc0
commit 05380e618f
No known key found for this signature in database
GPG Key ID: D6F1633A4F0903B8

View File

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"
"text/tabwriter"
"github.com/howeyc/gopass"
@ -262,9 +263,28 @@ func CmdListPosts(c *cli.Context) error {
}
func getPostURL(c *cli.Context, slug string) string {
base := config.WriteasBaseURL
if config.IsDev() {
base = config.DevBaseURL
var base string
if c.App.Name == "writeas" {
if config.IsDev() {
base = config.DevBaseURL
} else {
base = config.WriteasBaseURL
}
} else {
if host := api.HostURL(c); host != "" {
base = host
} else {
// TODO handle error, or load config globally, see T601
// https://phabricator.write.as/T601
cfg, _ := config.LoadConfig(config.UserDataDir(c.App.ExtraInfo()["configDir"]))
if cfg.Default.Host != "" && cfg.Default.User != "" {
if parts := strings.Split(cfg.Default.Host, "://"); len(parts) > 1 {
base = cfg.Default.Host
} else {
base = "https://" + cfg.Default.Host
}
}
}
}
ext := ""
// Output URL in requested format