Skip to content

Commit

Permalink
Update pretty relative index links to rewrite to . instead of /
Browse files Browse the repository at this point in the history
Update pretty relative index links to rewrite to `.` instead of `/` so they are indeed relative
  • Loading branch information
caendesilva committed Mar 8, 2023
1 parent 2b8c026 commit 2390b73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/framework/src/Foundation/Kernel/Hyperlinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public function relativeLink(string $destination): string
}
$route .= $this->formatLink($destination);

if (Config::getBool('hyde.pretty_urls', false) === true && $route === '/') {
return '.';
}

return str_replace('//', '/', $route);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testHelperRewritesIndexWhenUsingPrettyUrls()
{
self::mockConfig(['hyde.pretty_urls' => true]);
$this->mockCurrentPage('foo.html');
$this->assertEquals('/', Hyde::relativeLink('index.html'));
$this->assertEquals('.', Hyde::relativeLink('index.html'));
$this->mockCurrentPage('foo/bar.html');
$this->assertEquals('../', Hyde::relativeLink('index.html'));
$this->mockCurrentPage('foo/bar/baz.html');
Expand Down

0 comments on commit 2390b73

Please sign in to comment.