aboutsummaryrefslogtreecommitdiff
path: root/args_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-12-22 20:13:45 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2015-12-22 20:13:45 +0200
commitb3c0a2cf75c7e1e16c97f500a56b5621f0238607 (patch)
treef7319d4ef5c1dbaf95e28d3aec419943918b89c8 /args_test.go
parentImport fasthttp in server examples (diff)
downloadfasthttp-b3c0a2cf75c7e1e16c97f500a56b5621f0238607.tar.gz
fasthttp-b3c0a2cf75c7e1e16c97f500a56b5621f0238607.tar.bz2
fasthttp-b3c0a2cf75c7e1e16c97f500a56b5621f0238607.zip
Do not escape the most frequently used chars in uri path such as ':~=,'
Diffstat (limited to 'args_test.go')
-rw-r--r--args_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/args_test.go b/args_test.go
index fd0831b..0fe7be8 100644
--- a/args_test.go
+++ b/args_test.go
@@ -7,6 +7,21 @@ import (
"testing"
)
+func TestArgsEscape(t *testing.T) {
+ testArgsEscape(t, "foo", "bar", "foo=bar")
+ testArgsEscape(t, "f.o,1:2/4", "~`!@#$%^&*()_-=+\\|/[]{};:'\"<>,./?",
+ "f.o,1:2/4=%7E%60%21%40%23%24%25%5E%26%2A%28%29%5F%2D%3D%2B%5C%7C/%5B%5D%7B%7D%3B:%27%22%3C%3E,./%3F")
+}
+
+func testArgsEscape(t *testing.T, k, v, expectedS string) {
+ var a Args
+ a.Set(k, v)
+ s := a.String()
+ if s != expectedS {
+ t.Fatalf("unexpected args %q. Expecting %q. k=%q, v=%q", s, expectedS, k, v)
+ }
+}
+
func TestArgsWriteTo(t *testing.T) {
s := "foo=bar&baz=123&aaa=bbb"
@@ -256,6 +271,9 @@ func TestArgsParse(t *testing.T) {
// invalid percent encoding
testArgsParse(t, &a, "f%=x&qw%z=d%0k%20p&%%20=%%%20x", 3, "f%=x", "qw%z=d%0k p", "% =%% x")
+
+ // special chars
+ testArgsParse(t, &a, "a.b,c:d/e=f.g,h:i/q", 1, "a.b,c:d/e=f.g,h:i/q")
}
func TestArgsHas(t *testing.T) {