richard
/
cyca
Archived
1
0
Fork 0
This repository has been archived on 2024-05-04. You can view files and clone it, but cannot push or open issues or pull requests.
cyca/app/Helpers/Url.php

37 lines
750 B
PHP
Executable File

<?php
namespace App\Helpers;
use League\Uri\Http as UriHttp;
use League\Uri\UriResolver;
/**
* Helper to work with urls.
*/
class Url
{
/**
* Convert specified relative URL to an absolute URL using specified base
* URL.
*
* @param mixed $baseUrl
* @param mixed $relativeUrl
*
* @return string
*/
public static function makeUrlAbsolute($baseUrl, $relativeUrl)
{
if (\is_string($baseUrl)) {
$baseUrl = UriHttp::createFromString($baseUrl);
}
if (\is_string($relativeUrl)) {
$relativeUrl = UriHttp::createFromString($relativeUrl);
}
$newUri = UriResolver::resolve($relativeUrl, $baseUrl);
return (string) $newUri;
}
}