Skip to content

Commit 6874735

Browse files
author
Clemens John
committed
Use laravel url helper in calculateFullPath method. This fixes a bug with URLs containing a path (like http://localhost/path/to/app/myresource. Without this fix calculateFullPath delets the path between the host and myresource
Signed-off-by: Clemens John <clemens.john@floh1111.de>
1 parent e9cc1c4 commit 6874735

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/NilPortugues/Laravel5/JsonApi/Providers/Laravel52Provider.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function calculateRoute(array $value)
4242
if ($routerObject->getName() === $value['name']) {
4343
$route = $routerObject->getPath();
4444

45-
return $this->calculateFullPath($value, $route, $router);
45+
return $this->calculateFullPath($value, $route);
4646
}
4747
}
4848

@@ -79,19 +79,13 @@ protected function getRouterCollection(UrlGenerator $router)
7979
*
8080
* @return mixed|string
8181
*/
82-
protected function calculateFullPath(array &$value, $route, UrlGenerator $router)
82+
protected function calculateFullPath(array &$value, $route)
8383
{
8484
if (!empty($value['as_id'])) {
8585
preg_match_all('/{(.*?)}/', $route, $matches);
8686
$route = str_replace($matches[0], '{'.$value['as_id'].'}', $route);
8787
}
8888

89-
$port = parse_url($router->current(), PHP_URL_PORT);
90-
$port = (null === $port) ? '' : ':'.$port;
91-
92-
$scheme = parse_url($router->current(), PHP_URL_SCHEME);
93-
$host = parse_url($router->current(), PHP_URL_HOST).$port;
94-
95-
return sprintf('%s://%s/%s', $scheme, $host, $route);
89+
return url($route);
9690
}
9791
}

0 commit comments

Comments
 (0)