1 | <?php |
||||
2 | |||||
3 | namespace Sulao\LRTS\Routing; |
||||
4 | |||||
5 | use Illuminate\Routing\Exceptions\UrlGenerationException; |
||||
6 | use Illuminate\Routing\Route; |
||||
7 | use Illuminate\Support\Str; |
||||
8 | use Sulao\LRTS\Helper; |
||||
9 | |||||
10 | class UrlGenerator extends \Illuminate\Routing\UrlGenerator |
||||
11 | { |
||||
12 | /** |
||||
13 | * Get the URL for a given route instance. |
||||
14 | * |
||||
15 | * @param Route $route |
||||
16 | * @param mixed $parameters |
||||
17 | * @param bool $absolute |
||||
18 | * @return string |
||||
19 | * |
||||
20 | * @throws UrlGenerationException |
||||
21 | */ |
||||
22 | public function toRoute($route, $parameters, $absolute) |
||||
23 | { |
||||
24 | $url = parent::toRoute($route, $parameters, $absolute); |
||||
25 | |||||
26 | if (Str::endsWith($route->originalUri, '/')) { |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
27 | $arr = explode('?', $url); |
||||
28 | $arr[0] = Helper::appendSlashes($arr[0], $route->originalUri); |
||||
0 ignored issues
–
show
It seems like
$route->originalUri can also be of type object ; however, parameter $origin of Sulao\LRTS\Helper::appendSlashes() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
29 | $url = implode('?', $arr); |
||||
30 | } |
||||
31 | |||||
32 | return $url; |
||||
33 | } |
||||
34 | |||||
35 | /** |
||||
36 | * Generate an absolute URL to the given path. |
||||
37 | * |
||||
38 | * @param string $path |
||||
39 | * @param mixed $extra |
||||
40 | * @param bool|null $secure |
||||
41 | * |
||||
42 | * @return string |
||||
43 | */ |
||||
44 | public function to($path, $extra = [], $secure = null) |
||||
45 | { |
||||
46 | return Helper::appendSlashes( |
||||
47 | parent::to($path, $extra, $secure), |
||||
48 | $path |
||||
49 | ); |
||||
50 | } |
||||
51 | } |
||||
52 |