Cleaner way to build the canonical URL
This commit is contained in:
parent
68f2255fa0
commit
110bfc9ff1
1 changed files with 5 additions and 12 deletions
|
@ -13,6 +13,7 @@ use Alltube\Locale;
|
||||||
use Alltube\Middleware\CspMiddleware;
|
use Alltube\Middleware\CspMiddleware;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Slim\Http\StatusCode;
|
use Slim\Http\StatusCode;
|
||||||
|
use Slim\Http\Uri;
|
||||||
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
|
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
@ -332,19 +333,11 @@ class FrontController extends BaseController
|
||||||
*/
|
*/
|
||||||
private function getCanonicalUrl(Request $request)
|
private function getCanonicalUrl(Request $request)
|
||||||
{
|
{
|
||||||
|
/** @var Uri $uri */
|
||||||
$uri = $request->getUri();
|
$uri = $request->getUri();
|
||||||
$return = 'https://alltubedownload.net/';
|
|
||||||
|
|
||||||
$path = $uri->getPath();
|
return $uri->withBasePath('')
|
||||||
if ($path != '/') {
|
->withHost('alltubedownload.net')
|
||||||
$return .= $path;
|
->withScheme('https');
|
||||||
}
|
|
||||||
|
|
||||||
$query = $uri->getQuery();
|
|
||||||
if (!empty($query)) {
|
|
||||||
$return .= '?' . $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue