diff options
author | bep <[email protected]> | 2015-05-05 16:02:52 +0200 |
---|---|---|
committer | bep <[email protected]> | 2015-05-05 16:02:44 +0200 |
commit | bea9280fb35b156062e63afffd9d85ac5aac88f5 (patch) | |
tree | 4b70a598d06bdcefb2b2aba295c19c111b65235e /hugolib/site_url_test.go | |
parent | bef3df7481027254a6711965828cd120fa5deb7c (diff) | |
download | hugo-bea9280fb35b156062e63afffd9d85ac5aac88f5.tar.gz hugo-bea9280fb35b156062e63afffd9d85ac5aac88f5.zip |
Do not add trailing slash to baseURL
Fixes #1105
Diffstat (limited to 'hugolib/site_url_test.go')
-rw-r--r-- | hugolib/site_url_test.go | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index f2f25f80d..c7fc64e44 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -1,7 +1,6 @@ package hugolib import ( - "html/template" "path/filepath" "testing" @@ -10,6 +9,7 @@ import ( "github.com/spf13/hugo/source" "github.com/spf13/hugo/target" "github.com/spf13/viper" + "html/template" ) const SLUG_DOC_1 = "---\ntitle: slug doc 1\nslug: slug-doc-1\naliases:\n - sd1/foo/\n - sd2\n - sd3/\n - sd4.html\n---\nslug doc 1 content\n" @@ -52,6 +52,29 @@ var urlFakeSource = []source.ByteSource{ {filepath.FromSlash("content/blue/doc2.md"), []byte(SLUG_DOC_2)}, } +// Issue #1105 +func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) { + + for i, this := range []struct { + in string + expected string + }{ + {"http://base.com/", "http://base.com/"}, + {"http://base.com/sub/", "http://base.com/sub/"}, + {"http://base.com/sub", "http://base.com/sub"}, + {"http://base.com", "http://base.com"}} { + + viper.Set("BaseURL", this.in) + s := &Site{} + s.initializeSiteInfo() + + if s.Info.BaseURL != template.URL(this.expected) { + t.Errorf("[%d] got %s expected %s", i, s.Info.BaseURL, this.expected) + } + } + +} + func TestPageCount(t *testing.T) { hugofs.DestinationFS = new(afero.MemMapFs) |