aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-10-14 14:32:02 +0200
committerKim Alvefur <zash@zash.se>2018-10-14 14:32:02 +0200
commitba2688c78d1c6c7e092b6994b01e61fb1eaf34df (patch)
treec69cf99e8025c42af5ac630469e4a657a26ad152
parent0247a0e9049be42a0420a991feb9b9e9c7800bc0 (diff)
downloadprosody-ba2688c78d1c6c7e092b6994b01e61fb1eaf34df.tar.gz
prosody-ba2688c78d1c6c7e092b6994b01e61fb1eaf34df.zip
util.http: Add tests for normalize_path
-rw-r--r--spec/util_http_spec.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/util_http_spec.lua b/spec/util_http_spec.lua
index bacfcfb5..0f51a86c 100644
--- a/spec/util_http_spec.lua
+++ b/spec/util_http_spec.lua
@@ -61,4 +61,27 @@ describe("util.http", function()
});
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);