From e294eaa7afa33f74d2b8c335eaba19608e159e46 Mon Sep 17 00:00:00 2001 From: KJ Date: Thu, 9 May 2024 23:12:59 -0400 Subject: [PATCH] Add route function for View objects. --- src/Libs/View.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Libs/View.php b/src/Libs/View.php index cf0f052..9f878ba 100644 --- a/src/Libs/View.php +++ b/src/Libs/View.php @@ -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; + } } ?>