diff options
author | bep <[email protected]> | 2015-05-11 12:28:44 +0200 |
---|---|---|
committer | bep <[email protected]> | 2015-05-11 12:28:35 +0200 |
commit | be0cbeee7fb9b6e8af12745971ff80e86e0d3d32 (patch) | |
tree | bc69b9acabe55d40669deb545d1290fdd536c538 /helpers/url_test.go | |
parent | bec90e085055ef96cbd6a17604cf1020c2c82f24 (diff) | |
download | hugo-be0cbeee7fb9b6e8af12745971ff80e86e0d3d32.tar.gz hugo-be0cbeee7fb9b6e8af12745971ff80e86e0d3d32.zip |
Add absURL template func
Fixes #1106
Diffstat (limited to 'helpers/url_test.go')
-rw-r--r-- | helpers/url_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/helpers/url_test.go b/helpers/url_test.go index 1dabda273..3286c0f37 100644 --- a/helpers/url_test.go +++ b/helpers/url_test.go @@ -1,6 +1,7 @@ package helpers import ( + "github.com/spf13/viper" "github.com/stretchr/testify/assert" "strings" "testing" @@ -26,6 +27,28 @@ func TestURLize(t *testing.T) { } } +func TestAbsURL(t *testing.T) { + tests := []struct { + input string + baseURL string + expected string + }{ + {"/test/foo", "http://base/", "http://base/test/foo"}, + {"", "http://base/ace/", "http://base/ace/"}, + {"/test/2/foo/", "http://base", "http://base/test/2/foo/"}, + {"http://abs", "http://base/", "http://abs"}, + {"//schemaless", "http://base/", "//schemaless"}, + } + + for _, test := range tests { + viper.Set("BaseURL", test.baseURL) + output := AbsURL(test.input) + if output != test.expected { + t.Errorf("Expected %#v, got %#v\n", test.expected, output) + } + } +} + func TestSanitizeURL(t *testing.T) { tests := []struct { input string |