Changeset

9505:5203b6fd34d4

util.http: Add tests for normalize_path
author Kim Alvefur <zash@zash.se>
date Sun, 14 Oct 2018 14:32:02 +0200
parents 9504:cfbea3064aa9
children 9506:ae6636052be9
files spec/util_http_spec.lua
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);