diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-01-06 17:08:59 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2020-01-06 17:08:59 +0100 |
commit | 5b8009dbd06f9a09065843de8eb5f8f680bb4f37 (patch) | |
tree | 126eeaec3ab07312dd4f5c32f56faa47d4d6435b | |
parent | 9b6ceba4f1df99b262ebbcffcdb30b1ed16f9b42 (diff) | |
download | url-master.tar.gz url-master.tar.bz2 |
Thanks to chacewells@gmail.com for reporting this issue.
-rw-r--r-- | META6.json | 5 | ||||
-rw-r--r-- | lib/URL.pm6 | 2 | ||||
-rw-r--r-- | lib/URL/Grammar.pm6 | 4 | ||||
-rw-r--r-- | lib/URL/Grammar/Actions.pm6 | 2 | ||||
-rw-r--r-- | t/01-grammar.t | 20 |
5 files changed, 24 insertions, 9 deletions
@@ -4,7 +4,6 @@ "Patrick Spek <p.spek@tyil.work>" ], "depends": [ - ], "description": "A Raku library to parse and handle URLs", "license": "AGPL-3.0", @@ -17,11 +16,9 @@ "URL::Grammar::Actions": "lib/URL/Grammar/Actions.pm6" }, "resources": [ - ], "source-url": "https://gitlab.com/tyil/raku-url", "tags": [ - ], - "version": "0.2.0" + "version": "0.2.1" }
\ No newline at end of file diff --git a/lib/URL.pm6 b/lib/URL.pm6 index fa9ebc8..113d902 100644 --- a/lib/URL.pm6 +++ b/lib/URL.pm6 @@ -139,7 +139,7 @@ multi method Str ( =NAME URL =AUTHOR Patrick Spek <p.spek@tyil.work> -=VERSION 0.2.0 +=VERSION 0.2.1 =head1 Synopsis diff --git a/lib/URL/Grammar.pm6 b/lib/URL/Grammar.pm6 index 2f5cd45..e14f2a4 100644 --- a/lib/URL/Grammar.pm6 +++ b/lib/URL/Grammar.pm6 @@ -21,7 +21,7 @@ token password { <-[ @ ]>+ } token host { <hostname> [ ":" <port> ]? } token hostname { [ <-[ / : # ? \h ]>+ | "[" <-[ \] ]>+ "]" ] } token port { \d ** 1..5 } -token path { "/" <part=.path-part>* % "/" } +token path { "/" <part=.path-part>* %% "/" } token path-part { <-[ / ? # ]>+ } token query { <part=.query-part>* % "&" } token query-part { <key=.query-part-key> "=" <value=.query-part-value> } @@ -33,7 +33,7 @@ token fragment { <-[ \s ]>+ } =NAME URL::Grammar =AUTHOR Patrick Spek <p.spek@tyil.work> -=VERSION 0.2.0 +=VERSION 0.2.1 =head1 Synopsis diff --git a/lib/URL/Grammar/Actions.pm6 b/lib/URL/Grammar/Actions.pm6 index 2ef70bb..be7dc4e 100644 --- a/lib/URL/Grammar/Actions.pm6 +++ b/lib/URL/Grammar/Actions.pm6 @@ -32,7 +32,7 @@ method fragment ($/) { make ~$/ } =NAME URL::Grammar::Actions =AUTHOR Patrick Spek <p.spek@tyil.work> -=VERSION 0.2.0 +=VERSION 0.2.1 =head1 Synopsis 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<scheme>, "https", "Scheme is 'https'"; + nok $match<userinfo><username>, 'URL contains no username'; + nok $match<userinfo><password>, 'URL contains no password'; + is ~$match<host><hostname>, 'custom.endpoint', "Hostname is 'custom.endpoint'"; + nok $match<host><port>, 'URL contains no port'; + ok $match<path>, 'URL contains a path'; + is $match<path><part>.elems, 2, 'Path contains 2 elements'; + is ~$match<path><part>[0], 'foo', 'Path part 0 is "foo"'; + is ~$match<path><part>[1], 'bar', 'Path part 0 is "bar"'; + nok $match<query>, 'URL contains no query'; + nok $match<fragment>, 'URL contains no fragment'; +} + # vim: ft=perl6 noet |