Browse Source

fix post url for non standard hostnames

pull/36/head
Rob Loranger 4 years ago
parent
commit
05380e618f
No known key found for this signature in database GPG Key ID: D6F1633A4F0903B8
1 changed files with 23 additions and 3 deletions
  1. +23
    -3
      commands/commands.go

+ 23
- 3
commands/commands.go 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


Loading…
Cancel
Save