mirror of
https://github.com/friendica/friendica
synced 2025-05-05 17:44:10 +02:00
Enable "magic" with Hubzilla
This commit is contained in:
parent
5751311e99
commit
dca93a9606
8 changed files with 115 additions and 79 deletions
|
@ -29,6 +29,7 @@ use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
|||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientRequest;
|
||||
use Friendica\Network\HTTPException\NotModifiedException;
|
||||
use GuzzleHttp\Psr7\Exception\MalformedUriException;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
|
@ -670,4 +671,28 @@ class Network
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an Url parameter
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $parameter
|
||||
* @return string
|
||||
* @throws MalformedUriException
|
||||
*/
|
||||
public static function removeUrlParameter(string $url, string $parameter): string
|
||||
{
|
||||
$parts = parse_url($url);
|
||||
if (empty($parts['query'])) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
parse_str($parts['query'], $data);
|
||||
|
||||
unset($data[$parameter]);
|
||||
|
||||
$parts['query'] = http_build_query($data);
|
||||
|
||||
return (string)Uri::fromParts($parts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -498,7 +498,8 @@ class Strings
|
|||
|
||||
$blocks = [];
|
||||
|
||||
$return = preg_replace_callback($regex,
|
||||
$return = preg_replace_callback(
|
||||
$regex,
|
||||
function ($matches) use ($executionId, &$blocks) {
|
||||
$return = '«block-' . $executionId . '-' . count($blocks) . '»';
|
||||
|
||||
|
@ -516,7 +517,8 @@ class Strings
|
|||
$text = $callback($return ?? $text) ?? '';
|
||||
|
||||
// Restore code blocks
|
||||
$text = preg_replace_callback('/«block-' . $executionId . '-([0-9]+)»/iU',
|
||||
$text = preg_replace_callback(
|
||||
'/«block-' . $executionId . '-([0-9]+)»/iU',
|
||||
function ($matches) use ($blocks) {
|
||||
$return = $matches[0];
|
||||
if (isset($blocks[intval($matches[1])])) {
|
||||
|
@ -545,10 +547,10 @@ class Strings
|
|||
return $shorthand;
|
||||
}
|
||||
|
||||
$last = strtolower($shorthand[strlen($shorthand)-1]);
|
||||
$last = strtolower($shorthand[strlen($shorthand) - 1]);
|
||||
$shorthand = substr($shorthand, 0, -1);
|
||||
|
||||
switch($last) {
|
||||
switch ($last) {
|
||||
case 'g':
|
||||
$shorthand *= 1024;
|
||||
case 'm':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue