Skip to content

Commit 5020edf

Browse files
author
Wazabii
committed
Minor improvements
1 parent 5f9db43 commit 5020edf

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Url.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(RequestInterface $request, $path)
3333
// _ENV['APP_DIR'] is alos used and should be corrected
3434
$envDir = getenv("APP_PUBLIC_DIR");
3535
if (is_string($envDir) && $this->validateDir($envDir)) {
36-
$this->publicDirPath = ltrim(rtrim($envDir, "/"), "/")."/";
36+
$this->publicDirPath = ltrim(rtrim($envDir, "/"), "/");
3737
}
3838
}
3939

@@ -194,7 +194,7 @@ public function getDirPath(): string
194194
if (!is_string($this->dirPath)) {
195195
throw new \Exception("Could not create dirPath", 1);
196196
}
197-
return $this->dirPath.$this->publicDirPath;
197+
return $this->dirPath;
198198
}
199199

200200
/**
@@ -264,12 +264,12 @@ public function next(): string
264264
}
265265

266266
/**
267-
* Get root URL
267+
* Get root URL DIR
268268
* @param string $path add to URI
269269
* @param bool $endSlash add slash to the end of root URL (default false)
270270
* @return string
271271
*/
272-
public function getRoot(string $path = "", bool $endSlash = false): string
272+
public function getRootDir(string $path = "", bool $endSlash = false): string
273273
{
274274
$url = "";
275275
if ($scheme = $this->getScheme()) {
@@ -282,6 +282,19 @@ public function getRoot(string $path = "", bool $endSlash = false): string
282282
if ($dir = $this->getDirPath()) {
283283
$url .= rtrim($dir, "/");
284284
}
285+
return $url. (($endSlash) ? "/" : "") . $path;
286+
}
287+
288+
/**
289+
* Get root URL
290+
* @param string $path add to URI
291+
* @param bool $endSlash add slash to the end of root URL (default false)
292+
* @return string
293+
*/
294+
public function getRoot(string $path = "", bool $endSlash = false): string
295+
{
296+
$url = $this->getRootDir("/");
297+
$url .= $this->publicDirPath;
285298
return $url . (($endSlash) ? "/" : "") . $path;
286299
}
287300

@@ -322,7 +335,7 @@ public function getPublic(string $path = ""): string
322335
*/
323336
public function getResource(string $path = ""): string
324337
{
325-
return $this->getRoot("/resources/{$path}");
338+
return $this->getRootDir("/resources/{$path}");
326339
}
327340

328341
/**

0 commit comments

Comments
 (0)