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:
parent
b60ae1edc0
commit
05380e618f
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/howeyc/gopass"
|
"github.com/howeyc/gopass"
|
||||||
@ -262,9 +263,28 @@ func CmdListPosts(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPostURL(c *cli.Context, slug string) string {
|
func getPostURL(c *cli.Context, slug string) string {
|
||||||
base := config.WriteasBaseURL
|
var base string
|
||||||
if config.IsDev() {
|
if c.App.Name == "writeas" {
|
||||||
base = config.DevBaseURL
|
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 := ""
|
ext := ""
|
||||||
// Output URL in requested format
|
// Output URL in requested format
|
||||||
|
Loading…
Reference in New Issue
Block a user