Comparison

spec/util_http_spec.lua @ 11120:b2331f3dfeea

Merge 0.11->trunk
author Matthew Wild <mwild1@gmail.com>
date Wed, 30 Sep 2020 09:50:33 +0100
parent 10711:d2e4584ba7b3
child 13124:f15e23840780
comparison
equal deleted inserted replaced
11119:68df52bf08d5 11120:b2331f3dfeea
26 end); 26 end);
27 27
28 it("should decode important URL characters", function() 28 it("should decode important URL characters", function()
29 assert.are.equal("This & that = something", http.urldecode("This%20%26%20that%20%3d%20something"), "Important URL chars escaped"); 29 assert.are.equal("This & that = something", http.urldecode("This%20%26%20that%20%3d%20something"), "Important URL chars escaped");
30 end); 30 end);
31
32 it("should decode both lower and uppercase", function ()
33 assert.are.equal("This & that = {something}.", http.urldecode("This%20%26%20that%20%3D%20%7Bsomething%7D%2E"), "Important URL chars escaped");
34 end);
35
31 end); 36 end);
32 37
33 describe("#formencode()", function() 38 describe("#formencode()", function()
34 it("should encode basic data", function() 39 it("should encode basic data", function()
35 assert.are.equal(http.formencode({ { name = "one", value = "1"}, { name = "two", value = "2" } }), "one=1&two=2", "Form encoded"); 40 assert.are.equal(http.formencode({ { name = "one", value = "1"}, { name = "two", value = "2" } }), "one=1&two=2", "Form encoded");
82 assert.equal("/foo/", http.normalize_path("/foo", true)); 87 assert.equal("/foo/", http.normalize_path("/foo", true));
83 assert.equal("/foo/", http.normalize_path("foo/", true)); 88 assert.equal("/foo/", http.normalize_path("foo/", true));
84 assert.equal("/foo/", http.normalize_path("/foo/", true)); 89 assert.equal("/foo/", http.normalize_path("/foo/", true));
85 end); 90 end);
86 end); 91 end);
92
93 describe("contains_token", function ()
94 it("is present in field", function ()
95 assert.is_true(http.contains_token("foo", "foo"));
96 assert.is_true(http.contains_token("foo, bar", "foo"));
97 assert.is_true(http.contains_token("foo,bar", "foo"));
98 assert.is_true(http.contains_token("bar, foo,baz", "foo"));
99 end);
100
101 it("is absent from field", function ()
102 assert.is_false(http.contains_token("bar", "foo"));
103 assert.is_false(http.contains_token("fooo", "foo"));
104 assert.is_false(http.contains_token("foo o,bar", "foo"));
105 end);
106
107 it("is weird", function ()
108 assert.is_(http.contains_token("fo o", "foo"));
109 end);
110 end);
87 end); 111 end);