Compare commits

...

2 Commits

2 changed files with 16 additions and 1 deletions

View File

@ -82,7 +82,7 @@ class Router {
*/
public static function basePath(): string
{
if (defined('SITE_URL'))
if (defined('SITE_URL') && !empty(SITE_URL))
return parse_url(SITE_URL, PHP_URL_PATH);
return str_replace($_SERVER['DOCUMENT_ROOT'], '/', ROOT_DIR);
}

View File

@ -145,5 +145,20 @@ class View extends Neuron {
header('Content-Type: text/plain; charset=utf-8');
print($txt);
}
/**
* Intenta devolver la url absoluta a partir de una ruta relativa.
*
* @param string $path
*
* @return string
*/
public function route(string $path = '/'): string
{
if (defined('SITE_URL') && !empty(SITE_URL))
return SITE_URL.substr($path,1);
return $path;
}
}
?>