aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDiego Nehab <diego.nehab@gmail.com>2018-08-22 14:18:43 -0300
committerGitHub <noreply@github.com>2018-08-22 14:18:43 -0300
commit648d81281f177f43de3d7b66e5923bdbaaeb25d9 (patch)
treecf5a837a349305ad10b54d1ce152e7cdc490edfc /test
parent5813cd05054599b0409480d3214f1827c2360467 (diff)
parent043e99771352aff47680b99f09b66a32f0cc3ef5 (diff)
downloadluasocket-648d81281f177f43de3d7b66e5923bdbaaeb25d9.tar.gz
luasocket-648d81281f177f43de3d7b66e5923bdbaaeb25d9.tar.bz2
luasocket-648d81281f177f43de3d7b66e5923bdbaaeb25d9.zip
Merge pull request #256 from ewestbrook/luasocket254
url.lua:absolute_path(): fix issue #254
Diffstat (limited to 'test')
-rw-r--r--test/urltest.lua44
1 files changed, 39 insertions, 5 deletions
diff --git a/test/urltest.lua b/test/urltest.lua
index 1090a7e..ae8ba75 100644
--- a/test/urltest.lua
+++ b/test/urltest.lua
@@ -61,7 +61,7 @@ end
61local check_absolute_url = function(base, relative, absolute) 61local check_absolute_url = function(base, relative, absolute)
62 local res = socket.url.absolute(base, relative) 62 local res = socket.url.absolute(base, relative)
63 if res ~= absolute then 63 if res ~= absolute then
64 io.write("absolute: In test for '", relative, "' expected '", 64 io.write("absolute: In test for base='", base, "', rel='", relative, "' expected '",
65 absolute, "' but got '", res, "'\n") 65 absolute, "' but got '", res, "'\n")
66 os.exit() 66 os.exit()
67 end 67 end
@@ -627,25 +627,37 @@ check_absolute_url("http://a/b/c/d;p?q#f", "/g", "http://a/g")
627check_absolute_url("http://a/b/c/d;p?q#f", "//g", "http://g") 627check_absolute_url("http://a/b/c/d;p?q#f", "//g", "http://g")
628check_absolute_url("http://a/b/c/d;p?q#f", "?y", "http://a/b/c/d;p?y") 628check_absolute_url("http://a/b/c/d;p?q#f", "?y", "http://a/b/c/d;p?y")
629check_absolute_url("http://a/b/c/d;p?q#f", "g?y", "http://a/b/c/g?y") 629check_absolute_url("http://a/b/c/d;p?q#f", "g?y", "http://a/b/c/g?y")
630check_absolute_url("http://a/b/c/d;p?q#f", "g?y/./x", "http://a/b/c/g?y/./x") 630check_absolute_url("http://a/b/c/d;p?q#f", "g?y/./x", "http://a/b/c/g?y/x")
631check_absolute_url("http://a/b/c/d;p?q#f", "#s", "http://a/b/c/d;p?q#s") 631check_absolute_url("http://a/b/c/d;p?q#f", "#s", "http://a/b/c/d;p?q#s")
632check_absolute_url("http://a/b/c/d;p?q#f", "g#s", "http://a/b/c/g#s") 632check_absolute_url("http://a/b/c/d;p?q#f", "g#s", "http://a/b/c/g#s")
633check_absolute_url("http://a/b/c/d;p?q#f", "g#s/./x", "http://a/b/c/g#s/./x") 633check_absolute_url("http://a/b/c/d;p?q#f", "g#s/./x", "http://a/b/c/g#s/x")
634check_absolute_url("http://a/b/c/d;p?q#f", "g?y#s", "http://a/b/c/g?y#s") 634check_absolute_url("http://a/b/c/d;p?q#f", "g?y#s", "http://a/b/c/g?y#s")
635check_absolute_url("http://a/b/c/d;p?q#f", ";x", "http://a/b/c/d;x") 635check_absolute_url("http://a/b/c/d;p?q#f", ";x", "http://a/b/c/d;x")
636check_absolute_url("http://a/b/c/d;p?q#f", "g;x", "http://a/b/c/g;x") 636check_absolute_url("http://a/b/c/d;p?q#f", "g;x", "http://a/b/c/g;x")
637check_absolute_url("http://a/b/c/d;p?q#f", "g;x?y#s", "http://a/b/c/g;x?y#s") 637check_absolute_url("http://a/b/c/d;p?q#f", "g;x?y#s", "http://a/b/c/g;x?y#s")
638check_absolute_url("http://a/b/c/d;p?q#f", ".", "http://a/b/c/") 638check_absolute_url("http://a/b/c/d;p?q#f", ".", "http://a/b/c/")
639check_absolute_url("http://a/b/c/d;p?q#f", "./", "http://a/b/c/") 639check_absolute_url("http://a/b/c/d;p?q#f", "./", "http://a/b/c/")
640check_absolute_url("http://a/b/c/d;p?q#f", "./g", "http://a/b/c/g")
641check_absolute_url("http://a/b/c/d;p?q#f", "./g/", "http://a/b/c/g/")
642check_absolute_url("http://a/b/c/d;p?q#f", "././g", "http://a/b/c/g")
643check_absolute_url("http://a/b/c/d;p?q#f", "././g/", "http://a/b/c/g/")
644check_absolute_url("http://a/b/c/d;p?q#f", "g/.", "http://a/b/c/g/")
645check_absolute_url("http://a/b/c/d;p?q#f", "g/./", "http://a/b/c/g/")
646check_absolute_url("http://a/b/c/d;p?q#f", "g/./.", "http://a/b/c/g/")
647check_absolute_url("http://a/b/c/d;p?q#f", "g/././", "http://a/b/c/g/")
648check_absolute_url("http://a/b/c/d;p?q#f", "./.", "http://a/b/c/")
649check_absolute_url("http://a/b/c/d;p?q#f", "././.", "http://a/b/c/")
650check_absolute_url("http://a/b/c/d;p?q#f", "././g/./.", "http://a/b/c/g/")
640check_absolute_url("http://a/b/c/d;p?q#f", "..", "http://a/b/") 651check_absolute_url("http://a/b/c/d;p?q#f", "..", "http://a/b/")
641check_absolute_url("http://a/b/c/d;p?q#f", "../", "http://a/b/") 652check_absolute_url("http://a/b/c/d;p?q#f", "../", "http://a/b/")
642check_absolute_url("http://a/b/c/d;p?q#f", "../g", "http://a/b/g") 653check_absolute_url("http://a/b/c/d;p?q#f", "../g", "http://a/b/g")
643check_absolute_url("http://a/b/c/d;p?q#f", "../..", "http://a/") 654check_absolute_url("http://a/b/c/d;p?q#f", "../..", "http://a/")
644check_absolute_url("http://a/b/c/d;p?q#f", "../../", "http://a/") 655check_absolute_url("http://a/b/c/d;p?q#f", "../../", "http://a/")
645check_absolute_url("http://a/b/c/d;p?q#f", "../../g", "http://a/g") 656check_absolute_url("http://a/b/c/d;p?q#f", "../../g", "http://a/g")
657check_absolute_url("http://a/b/c/d;p?q#f", "../../../g", "http://a/g")
646check_absolute_url("http://a/b/c/d;p?q#f", "", "http://a/b/c/d;p?q#f") 658check_absolute_url("http://a/b/c/d;p?q#f", "", "http://a/b/c/d;p?q#f")
647check_absolute_url("http://a/b/c/d;p?q#f", "/./g", "http://a/./g") 659check_absolute_url("http://a/b/c/d;p?q#f", "/./g", "http://a/g")
648check_absolute_url("http://a/b/c/d;p?q#f", "/../g", "http://a/../g") 660check_absolute_url("http://a/b/c/d;p?q#f", "/../g", "http://a/g")
649check_absolute_url("http://a/b/c/d;p?q#f", "g.", "http://a/b/c/g.") 661check_absolute_url("http://a/b/c/d;p?q#f", "g.", "http://a/b/c/g.")
650check_absolute_url("http://a/b/c/d;p?q#f", ".g", "http://a/b/c/.g") 662check_absolute_url("http://a/b/c/d;p?q#f", ".g", "http://a/b/c/.g")
651check_absolute_url("http://a/b/c/d;p?q#f", "g..", "http://a/b/c/g..") 663check_absolute_url("http://a/b/c/d;p?q#f", "g..", "http://a/b/c/g..")
@@ -655,6 +667,17 @@ check_absolute_url("http://a/b/c/d;p?q#f", "./g/.", "http://a/b/c/g/")
655check_absolute_url("http://a/b/c/d;p?q#f", "g/./h", "http://a/b/c/g/h") 667check_absolute_url("http://a/b/c/d;p?q#f", "g/./h", "http://a/b/c/g/h")
656check_absolute_url("http://a/b/c/d;p?q#f", "g/../h", "http://a/b/c/h") 668check_absolute_url("http://a/b/c/d;p?q#f", "g/../h", "http://a/b/c/h")
657 669
670check_absolute_url("http://a/b/c/d:p?q#f/", "../g/", "http://a/b/g/")
671check_absolute_url("http://a/b/c/d:p?q#f/", "../g", "http://a/b/g")
672check_absolute_url("http://a/b/c/d:p?q#f/", "../.g/", "http://a/b/.g/")
673check_absolute_url("http://a/b/c/d:p?q#f/", "../.g", "http://a/b/.g")
674check_absolute_url("http://a/b/c/d:p?q#f/", "../.g.h/", "http://a/b/.g.h/")
675check_absolute_url("http://a/b/c/d:p?q#f/", "../.g.h", "http://a/b/.g.h")
676
677check_absolute_url("http://a/b/c/d:p?q#f/", "g.h/", "http://a/b/c/g.h/")
678check_absolute_url("http://a/b/c/d:p?q#f/", "../g.h/", "http://a/b/g.h/")
679check_absolute_url("http://a/", "../g.h/", "http://a/g.h/")
680
658-- extra tests 681-- extra tests
659check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f") 682check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f")
660check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f") 683check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f")
@@ -662,6 +685,17 @@ check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f")
662check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f") 685check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f")
663check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html", 686check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html",
664 "http://velox.telemar.com.br/dashboard/index.html") 687 "http://velox.telemar.com.br/dashboard/index.html")
688check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/")
689check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com/...badhost.com/")
690check_absolute_url("http://example.com/a/b/c/d/", "../q", "http://example.com/a/b/c/q")
691check_absolute_url("http://example.com/a/b/c/d/", "../../q", "http://example.com/a/b/q")
692check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q")
693check_absolute_url("http://example.com", ".badhost.com", "http://example.com/.badhost.com")
694check_absolute_url("http://example.com/a/b/c/d/", "..//../../../q", "http://example.com/a/q")
695check_absolute_url("http://example.com/a/b/c/d/", "..//a/../../../../q", "http://example.com/a/q")
696check_absolute_url("http://example.com/a/b/c/d/", "..//a/..//../../../q", "http://example.com/a/b/q")
697check_absolute_url("http://example.com/a/b/c/d/", "..//a/..///../../../../q", "http://example.com/a/b/q")
698check_absolute_url("http://example.com/a/b/c/d/", "../x/a/../y/z/../../../../q", "http://example.com/a/b/q")
665 699
666print("testing path parsing and composition") 700print("testing path parsing and composition")
667check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) 701check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })