url() and path() seem to be broken
Kolyunya opened this issue · 6 comments
Kolyunya commented
public function path($path, $args = [])
{
if ($args !== []) {
$path = array_merge([$path], $args);
}
return Url::to($path);
}
public function url($path, $args = [])
{
if ($args !== []) {
$path = array_merge([$path], $args);
}
return Url::to($path, true);
}
Both functions pass paths
to Url::to
as a strings when no arguments are provided. This results in original paths
being returned instead of URLs being created by Url::to
.
Kolyunya commented
@samdark thanks!
#46 intends to maintain BC but makes function behavior bit inconsistent:
- When we want to create a URL from path with parameters we can pass it (path) as a string like this:
url('foo/bar', {baz: quux})
. - But when we want to create a URL from path without parameters we must wrap it in an array:
url(['foo/bar'])
.
What could be the use-case of passing a regular string to Url::to
without parameters?
samdark commented
What could be the use-case of passing a regular string to Url::to without parameters?
Quoting docs:
- a string with a leading
@
: it is treated as an alias, and the corresponding aliased string
will be returned. - an empty string: the currently requested URL will be returned;
- a normal string: it will be returned as is.