aboutsummaryrefslogtreecommitdiffhomepage
path: root/helpers/url_test.go
diff options
context:
space:
mode:
authorbep <[email protected]>2015-05-11 12:28:44 +0200
committerbep <[email protected]>2015-05-11 12:28:35 +0200
commitbe0cbeee7fb9b6e8af12745971ff80e86e0d3d32 (patch)
treebc69b9acabe55d40669deb545d1290fdd536c538 /helpers/url_test.go
parentbec90e085055ef96cbd6a17604cf1020c2c82f24 (diff)
downloadhugo-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.go23
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