Page MenuHomePhabricator

D20149.id48110.diff
No OneTemporary

D20149.id48110.diff

diff --git a/src/parser/PhutilURI.php b/src/parser/PhutilURI.php
--- a/src/parser/PhutilURI.php
+++ b/src/parser/PhutilURI.php
@@ -297,6 +297,42 @@
return $this->insertQueryParam($key, $value);
}
+ public function removeAllQueryParams() {
+ $this->query = array();
+ return $this;
+ }
+
+ public function removeQueryParam($remove_key) {
+ list($remove_key) = phutil_http_parameter_pair($remove_key, '');
+
+ foreach ($this->query as $idx => $pair) {
+ list($key, $value) = $pair;
+
+ if ($key !== $remove_key) {
+ continue;
+ }
+
+ unset($this->query[$idx]);
+ }
+
+ $this->query = array_values($this->query);
+
+ return $this;
+ }
+
+ public function appendQueryParamsAsMap(array $map) {
+ foreach ($map as $key => $value) {
+ $this->appendQueryParam($key, $value);
+ }
+ return $this;
+ }
+
+ public function replaceQueryParam($replace_key, $replace_value) {
+ $this->removeQueryParam($replace_key);
+ $this->appendQueryParam($replace_key, $replace_value);
+ return $this;
+ }
+
private function insertQueryParam($key, $value, $idx = null) {
list($key, $value) = phutil_http_parameter_pair($key, $value);
diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -1623,7 +1623,7 @@
$ex);
}
- $key = (string)$key;
+ $key = phutil_string_cast($key);
try {
assert_stringlike($value);
@@ -1635,7 +1635,7 @@
$ex);
}
- $value = (string)$value;
+ $value = phutil_string_cast($value);
return array($key, $value);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 24, 1:45 AM (3 w, 22 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7719366
Default Alt Text
D20149.id48110.diff (1 KB)

Event Timeline