Skip to content

Commit aca0374

Browse files
committed
Improved getSubpath
1 parent f8237f9 commit aca0374

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

app/Utils/UrlUtils.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace App\Utils;
44

5+
use Illuminate\Support\Str;
6+
57
class UrlUtils {
68
/**
79
* When serving multiple applications (also already spacialist + thesaurex)
@@ -21,15 +23,8 @@ static function getSubPath(string $url) : string {
2123
if(!$doesMatch || !isset($matches[1])) {
2224
return '/';
2325
}
24-
$trimDefaultCharacters = " \n\r\t\v\0";
25-
// Remove all irrelevant characters from the subpath
26-
// including all leading and trailing slashes.
27-
$subPathUrl = trim($matches[1], $trimDefaultCharacters . '/');
28-
if(empty($subPathUrl)) {
29-
return '/';
30-
}
31-
32-
// Add leading slash to the subpath.
33-
return '/' . $subPathUrl;
26+
27+
$subpathUrl = trim($matches[1]);
28+
return Str::start(trim($subpathUrl, '/'), '/');
3429
}
3530
}

0 commit comments

Comments
 (0)