diff --git a/src/Foundation/Kernel/Hyperlinks.php b/src/Foundation/Kernel/Hyperlinks.php index 97558414..98b2acdc 100644 --- a/src/Foundation/Kernel/Hyperlinks.php +++ b/src/Foundation/Kernel/Hyperlinks.php @@ -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(); diff --git a/tests/Feature/Foundation/HyperlinksTest.php b/tests/Feature/Foundation/HyperlinksTest.php index 584b8e33..10eb5db9 100644 --- a/tests/Feature/Foundation/HyperlinksTest.php +++ b/tests/Feature/Foundation/HyperlinksTest.php @@ -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); } } @@ -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()