spec/util_http_spec.lua
changeset 9508 5203b6fd34d4
parent 8239 4878e4159e12
child 9789 ff88b03c343f
--- a/spec/util_http_spec.lua	Sun Oct 14 14:31:59 2018 +0200
+++ b/spec/util_http_spec.lua	Sun Oct 14 14:32:02 2018 +0200
@@ -61,4 +61,27 @@
 			});
 		end);
 	end);
+
+	describe("normalize_path", function ()
+		it("root path is always '/'", function ()
+			assert.equal("/", http.normalize_path("/"));
+			assert.equal("/", http.normalize_path(""));
+			assert.equal("/", http.normalize_path("/", true));
+			assert.equal("/", http.normalize_path("", true));
+		end);
+
+		it("works", function ()
+			assert.equal("/foo", http.normalize_path("foo"));
+			assert.equal("/foo", http.normalize_path("/foo"));
+			assert.equal("/foo", http.normalize_path("foo/"));
+			assert.equal("/foo", http.normalize_path("/foo/"));
+		end);
+
+		it("is_dir works", function ()
+			assert.equal("/foo/", http.normalize_path("foo", true));
+			assert.equal("/foo/", http.normalize_path("/foo", true));
+			assert.equal("/foo/", http.normalize_path("foo/", true));
+			assert.equal("/foo/", http.normalize_path("/foo/", true));
+		end);
+	end);
 end);