Skip to content

Commit

Permalink
Add config option and update getUrl()
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerkretzmar committed Jul 28, 2023
1 parent 995fa16 commit ec8c219
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/PageVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ public function getPaths()

public function getUrl($key = null)
{
$wrap = fn ($url) => $url . (
! str_ends_with($url, '/') && app('config')->get('trailing_slash') ? '/' : ''
);

if (($key || $this->_meta->extending) && $this->_meta->path instanceof IterableObject) {
return $this->_meta->url->get($key ?: $this->getExtending());
return $wrap($this->_meta->url->get($key ?: $this->getExtending()));
}

return (string) $this->_meta->url;
return $wrap((string) $this->_meta->url);
}

public function getUrls()
Expand Down
1 change: 1 addition & 0 deletions tests/snapshots/default-trailing-slash/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Illuminate\Support\Str;

return [
'trailing_slash' => true,
'baseUrl' => 'http://jigsaw.test',
'global_array' => [1, 2, 3],
'global_variable' => 'some global variable',
Expand Down

0 comments on commit ec8c219

Please sign in to comment.