From 5b8009dbd06f9a09065843de8eb5f8f680bb4f37 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 6 Jan 2020 17:08:59 +0100 Subject: Fix trailing / in URLs Thanks to chacewells@gmail.com for reporting this issue. --- t/01-grammar.t | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/01-grammar.t b/t/01-grammar.t index a84bf86..cf4e51f 100644 --- a/t/01-grammar.t +++ b/t/01-grammar.t @@ -5,7 +5,7 @@ use v6.d; use URL::Grammar; use Test; -plan 2; +plan 3; subtest "https://www.tyil.nl", { plan 8; @@ -58,4 +58,22 @@ subtest "https://tyil:donthackme\@www.tyil.nl:8443/a/path/part?foo=bar&perl=6#mo } } +subtest 'https://custom.endpoint/foo/bar/', { + plan 11; + + my $match = URL::Grammar.parse('https://custom.endpoint/foo/bar/'); + + is ~$match, "https", "Scheme is 'https'"; + nok $match, 'URL contains no username'; + nok $match, 'URL contains no password'; + is ~$match, 'custom.endpoint', "Hostname is 'custom.endpoint'"; + nok $match, 'URL contains no port'; + ok $match, 'URL contains a path'; + is $match.elems, 2, 'Path contains 2 elements'; + is ~$match[0], 'foo', 'Path part 0 is "foo"'; + is ~$match[1], 'bar', 'Path part 0 is "bar"'; + nok $match, 'URL contains no query'; + nok $match, 'URL contains no fragment'; +} + # vim: ft=perl6 noet -- cgit v1.1