aboutsummaryrefslogtreecommitdiff
path: root/uri_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-02-09 20:16:23 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-02-09 20:16:23 +0200
commit5507d704f907651179c4464a79305b627634765a (patch)
tree5d49d07907948f2b1c66c1eb0f0c71d6a4847174 /uri_test.go
parentAdded BodyWriteTo to Request and Response (diff)
downloadfasthttp-5507d704f907651179c4464a79305b627634765a.tar.gz
fasthttp-5507d704f907651179c4464a79305b627634765a.tar.bz2
fasthttp-5507d704f907651179c4464a79305b627634765a.zip
Issue #48: added more tests and code prettifying after PR #50
Diffstat (limited to 'uri_test.go')
-rw-r--r--uri_test.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/uri_test.go b/uri_test.go
index 5cbab28..b02fe95 100644
--- a/uri_test.go
+++ b/uri_test.go
@@ -50,9 +50,10 @@ func TestURIUpdate(t *testing.T) {
// relative uri
testURIUpdate(t, "http://foo.bar/baz/xxx.html?aaa=22#aaa", "bb.html?xx=12#pp", "http://foo.bar/baz/bb.html?xx=12#pp")
testURIUpdate(t, "http://xx/a/b/c/d", "../qwe/p?zx=34", "http://xx/a/b/qwe/p?zx=34")
- testURIUpdate(t, "https://qqq/aaa.html?foo=bar", "?baz=434&aaa", "https://qqq/aaa.html?baz=434&aaa")
+ testURIUpdate(t, "https://qqq/aaa.html?foo=bar", "?baz=434&aaa#xcv", "https://qqq/aaa.html?baz=434&aaa#xcv")
testURIUpdate(t, "http://foo.bar/baz", "~a/%20b=c,тест?йцу=ке", "http://foo.bar/~a/%20b=c,%D1%82%D0%B5%D1%81%D1%82?йцу=ке")
testURIUpdate(t, "http://foo.bar/baz", "/qwe#fragment", "http://foo.bar/qwe#fragment")
+ testURIUpdate(t, "http://foobar/baz/xxx", "aaa.html#bb?cc=dd&ee=dfd", "http://foobar/baz/aaa.html#bb?cc=dd&ee=dfd")
}
func testURIUpdate(t *testing.T, base, update, result string) {
@@ -195,6 +196,10 @@ func TestURIParse(t *testing.T) {
testURIParse(t, &u, "foobar.com", "/a.b.c?def=gkl#mnop",
"http://foobar.com/a.b.c?def=gkl#mnop", "foobar.com", "/a.b.c", "/a.b.c", "def=gkl", "mnop")
+ // '?' and '#' in hash
+ testURIParse(t, &u, "aaa.com", "/foo#bar?baz=aaa#bbb",
+ "http://aaa.com/foo#bar?baz=aaa#bbb", "aaa.com", "/foo", "/foo", "", "bar?baz=aaa#bbb")
+
// encoded path
testURIParse(t, &u, "aa.com", "/Test%20+%20%D0%BF%D1%80%D0%B8?asdf=%20%20&s=12#sdf",
"http://aa.com/Test%20%2B%20%D0%BF%D1%80%D0%B8?asdf=%20%20&s=12#sdf", "aa.com", "/Test + при", "/Test%20+%20%D0%BF%D1%80%D0%B8", "asdf=%20%20&s=12", "sdf")