Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup and refactors #1727

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/framework/src/Foundation/Kernel/Hyperlinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ public function hasSiteUrl(): bool
/**
* Return a qualified URL to the supplied path if a base URL is set.
*
* @param string $path optional relative path suffix. Omit to return base url.
* @param string $path An optional relative path suffix. Omit to return the base URL.
*
* @throws BaseUrlNotSetException If no site URL is set and no default is provided
* @throws BaseUrlNotSetException If no site URL is set and no path is provided.
*/
public function url(string $path = ''): string
{
$path = $this->formatLink(trim($path, '/'));

if ($this->hasSiteUrl()) {
return rtrim(rtrim((string) Config::getNullableString('hyde.url'), '/')."/$path", '/');
return rtrim(rtrim(Config::getString('hyde.url'), '/')."/$path", '/');
}

throw new BaseUrlNotSetException();
Expand Down
12 changes: 6 additions & 6 deletions packages/framework/tests/Feature/Foundation/HyperlinksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testAssetHelperGetsRelativeWebLinkToImageStoredInSiteMediaFolder
];

foreach ($tests as $input => $expected) {
$this->assertEquals($this->class->asset($input), $expected);
$this->assertSame($this->class->asset($input), $expected);
}
}

Expand All @@ -50,30 +50,30 @@ public function testAssetHelperResolvesPathsForNestedPages()

foreach ($tests as $input => $expected) {
$this->mockCurrentPage('foo/bar');
$this->assertEquals($this->class->asset($input), $expected);
$this->assertSame($this->class->asset($input), $expected);
}
}

public function testAssetHelperReturnsQualifiedAbsoluteUriWhenRequestedAndSiteHasBaseUrl()
{
$this->assertEquals('http://localhost/media/test.jpg', $this->class->asset('test.jpg', true));
$this->assertSame('http://localhost/media/test.jpg', $this->class->asset('test.jpg', true));
}

public function testAssetHelperReturnsDefaultRelativePathWhenQualifiedAbsoluteUriIsRequestedButSiteHasNoBaseUrl()
{
config(['hyde.url' => null]);
$this->assertEquals('media/test.jpg', $this->class->asset('test.jpg', true));
$this->assertSame('media/test.jpg', $this->class->asset('test.jpg', true));
}

public function testAssetHelperReturnsInputWhenQualifiedAbsoluteUriIsRequestedButImageIsAlreadyQualified()
{
$this->assertEquals('http://localhost/media/test.jpg', $this->class->asset('http://localhost/media/test.jpg', true));
$this->assertSame('http://localhost/media/test.jpg', $this->class->asset('http://localhost/media/test.jpg', true));
}

public function testAssetHelperUsesConfiguredMediaDirectory()
{
Hyde::setMediaDirectory('_assets');
$this->assertEquals('assets/test.jpg', $this->class->asset('test.jpg'));
$this->assertSame('assets/test.jpg', $this->class->asset('test.jpg'));
}

public function testMediaLinkHelper()
Expand Down
Loading