handle https prefixes in baseUrl
authorMantas <mojavosas@gmail.com>
Mon, 6 Oct 2014 09:50:44 +0000 (12:50 +0300)
committerspf13 <steve.francia@gmail.com>
Tue, 7 Oct 2014 21:18:45 +0000 (17:18 -0400)
commands/server.go
commands/server_test.go

index ee30b927551f93d9653fe0704d353371813c5171..4d2a7335d83fd67f19bc94406e49ece25aa01e6f 100644 (file)
@@ -136,7 +136,7 @@ func fixUrl(s string) (string, error) {
                s = viper.GetString("BaseUrl")
                useLocalhost = true
        }
-       if !strings.HasPrefix(s, "http://") {
+       if !strings.HasPrefix(s, "http://") && !strings.HasPrefix(s, "https://") {
                s = "http://" + s
        }
        u, err := url.Parse(s)
index d8457964231348a9342e6729ee4e66d401607ea5..f2a292037375e820b7a93d3253d3272ab4da6026 100644 (file)
@@ -16,7 +16,8 @@ func TestFixUrl(t *testing.T) {
                Result     string
        }
        tests := []data{
-               {"Basic localhost", "", "http://foo.com", true, 1313, "http://localhost:1313"},
+               {"Basic http localhost", "", "http://foo.com", true, 1313, "http://localhost:1313"},
+               {"Basic https localhost", "", "https://foo.com", true, 1313, "https://localhost:1313"},
                {"Basic subdir", "", "http://foo.com/bar", true, 1313, "http://localhost:1313/bar"},
                {"Basic production", "http://foo.com", "http://foo.com", false, 80, "http://foo.com"},
                {"Production subdir", "http://foo.com/bar", "http://foo.com/bar", false, 80, "http://foo.com/bar"},