aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2019-04-09 20:27:30 +0200
committerPatrick Spek <p.spek@tyil.nl>2019-04-09 20:27:30 +0200
commitc0d52b7c34ce2889944cce5a92e949488ff47234 (patch)
tree31741f20ee35c99f65043fa50435325b59c4bb40
parent1bd1dff6d449ab221e191679fd8ec516b7cc1d4e (diff)
Add methods to add query and path parts
-rw-r--r--CHANGELOG.md6
-rw-r--r--META6.json2
-rw-r--r--lib/URL.pm632
-rw-r--r--lib/URL/Grammar.pm62
-rw-r--r--lib/URL/Grammar/Actions.pm62
5 files changed, 39 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c073e0e..719da21 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,5 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).
+## [0.2.0] - 2019-04-09
+- Add `add-path` method, to add parts to the path of a URL. This method returns
+ a new instance of the URL object.
+- Add `add-query` method, to add parts to the query of a URL. This method returns
+ a new instance of the URL object.
+
## [0.1.0] - 2019-04-08
- Initial release
diff --git a/META6.json b/META6.json
index f938a5a..a3565b4 100644
--- a/META6.json
+++ b/META6.json
@@ -23,5 +23,5 @@
"tags": [
],
- "version": "0.1.0"
+ "version": "0.2.0"
} \ No newline at end of file
diff --git a/lib/URL.pm6 b/lib/URL.pm6
index 57235b4..fa9ebc8 100644
--- a/lib/URL.pm6
+++ b/lib/URL.pm6
@@ -25,7 +25,7 @@ multi method new (
samewith(
|%match,
- path => %match<path>.list
+ path => %match<path>.list,
);
}
@@ -51,6 +51,34 @@ multi method new (
);
}
+#| Append one or more parts to the path of the URL.
+method add-path (
+ *@parts,
+
+ --> URL
+) {
+ return self.new(|self.Hash) unless @parts;
+
+ self.new(
+ |self.Hash,
+ path => [|@!path, |@parts],
+ );
+}
+
+#| Append one or more query parameters to the URL.
+method add-query (
+ *%parts,
+
+ --> URL
+) {
+ return self.new(|self.Hash) unless %parts;
+
+ self.new(
+ |self.Hash,
+ query => %(|%!query, |%parts),
+ );
+}
+
method Hash (
--> Hash
) {
@@ -111,7 +139,7 @@ multi method Str (
=NAME URL
=AUTHOR Patrick Spek <p.spek@tyil.work>
-=VERSION 0.1.0
+=VERSION 0.2.0
=head1 Synopsis
diff --git a/lib/URL/Grammar.pm6 b/lib/URL/Grammar.pm6
index cc9f13c..2f5cd45 100644
--- a/lib/URL/Grammar.pm6
+++ b/lib/URL/Grammar.pm6
@@ -33,7 +33,7 @@ token fragment { <-[ \s ]>+ }
=NAME URL::Grammar
=AUTHOR Patrick Spek <p.spek@tyil.work>
-=VERSION 0.1.0
+=VERSION 0.2.0
=head1 Synopsis
diff --git a/lib/URL/Grammar/Actions.pm6 b/lib/URL/Grammar/Actions.pm6
index 2015073..2ef70bb 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.1.0
+=VERSION 0.2.0
=head1 Synopsis