Fix code style

This commit is contained in:
Art4 2025-02-14 12:15:17 +00:00
parent b9a401454d
commit ce4e77fbb6
2 changed files with 24 additions and 22 deletions

View file

@ -81,15 +81,17 @@ class OEmbed
if (@$dom->loadHTML($html_text)) { if (@$dom->loadHTML($html_text)) {
$xpath = new DOMXPath($dom); $xpath = new DOMXPath($dom);
foreach ( foreach (
$xpath->query("//link[@type='application/json+oembed'] | //link[@type='text/json+oembed']") $xpath->query("//link[@type='application/json+oembed'] | //link[@type='text/json+oembed']") as $link
as $link) ) {
{
/** @var DOMElement $link */ /** @var DOMElement $link */
$href = $link->getAttributeNode('href')->nodeValue; $href = $link->getAttributeNode('href')->nodeValue;
// Both Youtube and Vimeo output OEmbed endpoint URL with HTTP // Both Youtube and Vimeo output OEmbed endpoint URL with HTTP
// but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯ // but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
$href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'], $href = str_replace(
['https://www.youtube.com/', 'https://player.vimeo.com/'], $href); ['http://www.youtube.com/', 'http://player.vimeo.com/'],
['https://www.youtube.com/', 'https://player.vimeo.com/'],
$href
);
$result = DI::httpClient()->get($href . '&maxwidth=' . $appHelper->getThemeInfoValue('videowidth'), HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SITEINFO]); $result = DI::httpClient()->get($href . '&maxwidth=' . $appHelper->getThemeInfoValue('videowidth'), HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SITEINFO]);
if ($result->isSuccess()) { if ($result->isSuccess()) {
$json_string = $result->getBodyString(); $json_string = $result->getBodyString();
@ -285,7 +287,7 @@ class OEmbed
} }
$ret .= '</div>'; $ret .= '</div>';
$test = Proxy::proxifyHtml($ret, $uriid); $test = Proxy::proxifyHtml($ret, $uriid);
return str_replace("\n", "", $ret); return str_replace("\n", "", $ret);
} }

View file

@ -164,7 +164,7 @@ class HookEventBridgeTest extends TestCase
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook'); $reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
$reflectionProperty->setAccessible(true); $reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, function (string $name, $data): string { $reflectionProperty->setValue(null, function (string $name, string $data): string {
$this->assertSame('oembed_fetch_url', $name); $this->assertSame('oembed_fetch_url', $name);
$this->assertSame('original_url', $data); $this->assertSame('original_url', $data);