Merge pull request #42 from MrPetovan/master

Use byjg/uri dependency instead of adding new URL-handling library
This commit is contained in:
Michael Vogel 2020-06-14 21:31:21 +02:00 committed by GitHub
commit 2eca458ec1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 56 deletions

View file

@ -20,6 +20,7 @@
"atlas/pdo": "^1.1", "atlas/pdo": "^1.1",
"boronczyk/localization-middleware": "^1.4", "boronczyk/localization-middleware": "^1.4",
"byjg/migration": "^4.0", "byjg/migration": "^4.0",
"byjg/uri": "^1.0.4",
"byjg/webrequest": "^1.0", "byjg/webrequest": "^1.0",
"gettext/gettext": "^4.6", "gettext/gettext": "^4.6",
"gofabian/negotiation-middleware": "^0.1.3", "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", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "0179cccd89f6bd7fd8ade738431b1a3b", "content-hash": "4ec1d35a2434e8cd6887500404ad427b",
"packages": [ "packages": [
{ {
"name": "asika/simple-console", "name": "asika/simple-console",
@ -556,6 +556,7 @@
], ],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)", "description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"homepage": "https://github.com/container-interop/container-interop", "homepage": "https://github.com/container-interop/container-interop",
"abandoned": "psr/container",
"time": "2017-02-14T19:40:03+00:00" "time": "2017-02-14T19:40:03+00:00"
}, },
{ {
@ -622,12 +623,12 @@
"version": "v4.6.2", "version": "v4.6.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/oscarotero/Gettext.git", "url": "https://github.com/php-gettext/Gettext.git",
"reference": "93176b272d61fb58a9767be71c50d19149cb1e48" "reference": "93176b272d61fb58a9767be71c50d19149cb1e48"
}, },
"dist": { "dist": {
"type": "zip", "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", "reference": "93176b272d61fb58a9767be71c50d19149cb1e48",
"shasum": "" "shasum": ""
}, },
@ -684,12 +685,12 @@
"version": "2.5.0", "version": "2.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mlocati/cldr-to-gettext-plural-rules.git", "url": "https://github.com/php-gettext/Languages.git",
"reference": "78db2d17933f0765a102f368a6663f057162ddbd" "reference": "78db2d17933f0765a102f368a6663f057162ddbd"
}, },
"dist": { "dist": {
"type": "zip", "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", "reference": "78db2d17933f0765a102f368a6663f057162ddbd",
"shasum": "" "shasum": ""
}, },
@ -1694,6 +1695,7 @@
"escaper", "escaper",
"zf" "zf"
], ],
"abandoned": "laminas/laminas-escaper",
"time": "2018-04-25T15:48:53+00:00" "time": "2018-04-25T15:48:53+00:00"
} }
], ],
@ -1950,6 +1952,7 @@
"scss", "scss",
"stylesheet" "stylesheet"
], ],
"abandoned": "scssphp/scssphp",
"time": "2018-07-22T01:22:08+00:00" "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; namespace Friendica\Directory\Views;
use Friendica\Directory\Utils\Url;
use Slim\Router; use Slim\Router;
/** /**
@ -206,18 +205,9 @@ class PhpRenderer extends \Slim\Views\PhpRenderer
function u(string $url) function u(string $url)
{ {
if ($this->getAttribute('zrl')) { if ($this->getAttribute('zrl')) {
$queryParameters = []; $uri = new \ByJG\Util\Uri($url);
$uri->withQueryKeyValue('zrl', $this->getAttribute('zrl'));
$parsed = parse_url($url); $url = $uri->__toString();
if (!empty($parsed['query'])) {
parse_str($parsed['query'], $queryParameters);
}
$queryParameters['zrl'] = $this->getAttribute('zrl');
$parsed['query'] = http_build_query($queryParameters);
$url = Url::unparse($parsed);
} }
return $url; return $url;