mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-13 20:24:00 +02:00
handle https prefixes in baseUrl
This commit is contained in:
@@ -136,7 +136,7 @@ func fixUrl(s string) (string, error) {
|
|||||||
s = viper.GetString("BaseUrl")
|
s = viper.GetString("BaseUrl")
|
||||||
useLocalhost = true
|
useLocalhost = true
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(s, "http://") {
|
if !strings.HasPrefix(s, "http://") && !strings.HasPrefix(s, "https://") {
|
||||||
s = "http://" + s
|
s = "http://" + s
|
||||||
}
|
}
|
||||||
u, err := url.Parse(s)
|
u, err := url.Parse(s)
|
||||||
|
@@ -16,7 +16,8 @@ func TestFixUrl(t *testing.T) {
|
|||||||
Result string
|
Result string
|
||||||
}
|
}
|
||||||
tests := []data{
|
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 subdir", "", "http://foo.com/bar", true, 1313, "http://localhost:1313/bar"},
|
||||||
{"Basic production", "http://foo.com", "http://foo.com", false, 80, "http://foo.com"},
|
{"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"},
|
{"Production subdir", "http://foo.com/bar", "http://foo.com/bar", false, 80, "http://foo.com/bar"},
|
||||||
|
Reference in New Issue
Block a user