Use byjg/uri dependency instead of adding new URL-handling library #42

Merged
MrPetovan merged 2 commits from master into master 2020-06-14 21:31:22 +02:00
4 changed files with 12 additions and 56 deletions

View file

@ -20,6 +20,7 @@
"atlas/pdo": "^1.1",
"boronczyk/localization-middleware": "^1.4",
"byjg/migration": "^4.0",
"byjg/uri": "^1.0.4",
"byjg/webrequest": "^1.0",
"gettext/gettext": "^4.6",
"gofabian/negotiation-middleware": "^0.1.3",

13
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0179cccd89f6bd7fd8ade738431b1a3b",
"content-hash": "4ec1d35a2434e8cd6887500404ad427b",
"packages": [
{
"name": "asika/simple-console",
@ -556,6 +556,7 @@
],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"homepage": "https://github.com/container-interop/container-interop",
"abandoned": "psr/container",
"time": "2017-02-14T19:40:03+00:00"
},
{
@ -622,12 +623,12 @@
"version": "v4.6.2",
"source": {
"type": "git",
"url": "https://github.com/oscarotero/Gettext.git",
"url": "https://github.com/php-gettext/Gettext.git",
"reference": "93176b272d61fb58a9767be71c50d19149cb1e48"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/oscarotero/Gettext/zipball/93176b272d61fb58a9767be71c50d19149cb1e48",
"url": "https://api.github.com/repos/php-gettext/Gettext/zipball/93176b272d61fb58a9767be71c50d19149cb1e48",
"reference": "93176b272d61fb58a9767be71c50d19149cb1e48",
"shasum": ""
},
@ -684,12 +685,12 @@
"version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/mlocati/cldr-to-gettext-plural-rules.git",
"url": "https://github.com/php-gettext/Languages.git",
"reference": "78db2d17933f0765a102f368a6663f057162ddbd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mlocati/cldr-to-gettext-plural-rules/zipball/78db2d17933f0765a102f368a6663f057162ddbd",
"url": "https://api.github.com/repos/php-gettext/Languages/zipball/78db2d17933f0765a102f368a6663f057162ddbd",
"reference": "78db2d17933f0765a102f368a6663f057162ddbd",
"shasum": ""
},
@ -1694,6 +1695,7 @@
"escaper",
"zf"
],
"abandoned": "laminas/laminas-escaper",
"time": "2018-04-25T15:48:53+00:00"
}
],
@ -1950,6 +1952,7 @@
"scss",
"stylesheet"
],
"abandoned": "scssphp/scssphp",
"time": "2018-07-22T01:22:08+00:00"
},
{

View file

@ -1,38 +0,0 @@
<?php
namespace Friendica\Directory\Utils;
/**
* URL related static utilities
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
* @package Friendica\Directory\Utils
*/
class Url
{
/**
* Mirror of parse_url function, puts components back together to form a URI.
*
* @param array $parsed
* @return string
*/
public static function unparse(array $parsed)
{
$scheme = $parsed['scheme'] ?? null;
$user = $parsed['user'] ?? null;
$pass = $parsed['pass'] ?? null;
$userinfo = $pass !== null ? "$user:$pass" : $user;
$port = $parsed['port'] ?? null;
$query = $parsed['query'] ?? null;
$fragment = $parsed['fragment'] ?? null;
$authority = ($userinfo !== null ? $userinfo . "@" : '') .
($parsed['host'] ?? '') .
($port ? ":$port" : '');
return (!empty($scheme) ? $scheme . ":" : '') .
(strlen($authority) ? "//" . $authority : '') .
($parsed['path'] ?? '') .
(strlen($query) ? "?" . $query : '') .
(strlen($fragment) ? "#" . $fragment : '');
}
}

View file

@ -2,7 +2,6 @@
namespace Friendica\Directory\Views;
use Friendica\Directory\Utils\Url;
use Slim\Router;
/**
@ -206,18 +205,9 @@ class PhpRenderer extends \Slim\Views\PhpRenderer
function u(string $url)
{
if ($this->getAttribute('zrl')) {
$queryParameters = [];
$parsed = parse_url($url);
if (!empty($parsed['query'])) {
parse_str($parsed['query'], $queryParameters);
}
$queryParameters['zrl'] = $this->getAttribute('zrl');
$parsed['query'] = http_build_query($queryParameters);
$url = Url::unparse($parsed);
$uri = new \ByJG\Util\Uri($url);
$uri->withQueryKeyValue('zrl', $this->getAttribute('zrl'));
$url = $uri->__toString();
}
return $url;