mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 09:54:03 +00:00
Merge 0b2ff24cac into 0a2eef4db4
This commit is contained in:
commit
f4b40ca38d
2 changed files with 16 additions and 2 deletions
|
|
@ -224,9 +224,13 @@ class SEOManager
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Append canonical URL tags to the document head. */
|
/** Append canonical URL tags to the document head. */
|
||||||
public function withUrl(): static
|
public function withUrl(?string $origin = null): static
|
||||||
{
|
{
|
||||||
|
if ($origin) {
|
||||||
|
$this->url(trim($origin, '/') . '/' . trim(request()->path(), '/'));
|
||||||
|
} else {
|
||||||
$this->url(request()->url());
|
$this->url(request()->url());
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,16 @@ test('canonical url can be read from request', function () {
|
||||||
->toContain('<link rel="canonical" href="http://localhost">');
|
->toContain('<link rel="canonical" href="http://localhost">');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('canonical url accepts origin', function () {
|
||||||
|
$this->get('/testing/5');
|
||||||
|
|
||||||
|
seo()->withUrl('https://foo.com');
|
||||||
|
|
||||||
|
expect(meta())
|
||||||
|
->toContain('<meta property="og:url" content="https://foo.com/testing/5">')
|
||||||
|
->toContain('<link rel="canonical" href="https://foo.com/testing/5">');
|
||||||
|
});
|
||||||
|
|
||||||
test('canonical url can be changed', function () {
|
test('canonical url can be changed', function () {
|
||||||
seo()->withUrl();
|
seo()->withUrl();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue