From: Hypolite Petovan Date: Sat, 12 Jan 2019 00:27:56 +0000 (-0500) Subject: Add ensureQueryParameter method to Util\Strings X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a20fa6a3a93475d6707f1a1aeedc4edc692935d9;p=friendica.git Add ensureQueryParameter method to Util\Strings --- diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 473774b71d..a11ac2fd58 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -312,4 +312,20 @@ class Strings { return (strcasecmp(self::normaliseLink($a), self::normaliseLink($b)) === 0); } + + + /** + * Ensures the provided URI has its query string punctuation in order. + * + * @param string $uri + * @return string + */ + public static function ensureQueryParameter($uri) + { + if (strpos($uri, '?') === false && ($pos = strpos($uri, '&')) !== false) { + $uri = substr($uri, 0, $pos) . '?' . substr($uri, $pos + 1); + } + + return $uri; + } }