From 7ff2ff9883cd73fdb4a85ec4122d93c1eec42094 Mon Sep 17 00:00:00 2001 From: Ben Bjurstrom Date: Wed, 4 Sep 2024 09:54:32 -0700 Subject: [PATCH 1/5] Update withUrl --- src/SEOManager.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SEOManager.php b/src/SEOManager.php index 2cfd4c4..706f2fb 100644 --- a/src/SEOManager.php +++ b/src/SEOManager.php @@ -224,9 +224,13 @@ class SEOManager } /** Append canonical URL tags to the document head. */ - public function withUrl(): static + public function withUrl(?string $origin = null): static { - $this->url(request()->url()); + if($origin){ + $this->url(trim($origin, '/') . '/' . trim(request()->path(), '/')); + }else{ + $this->url(request()->url()); + } return $this; } From cbb33fa269bb074f1737f8f9a0004f5ade984217 Mon Sep 17 00:00:00 2001 From: Ben Bjurstrom Date: Wed, 4 Sep 2024 09:54:37 -0700 Subject: [PATCH 2/5] Add test --- tests/Pest/ManagerTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Pest/ManagerTest.php b/tests/Pest/ManagerTest.php index aa9f25b..9c700f4 100644 --- a/tests/Pest/ManagerTest.php +++ b/tests/Pest/ManagerTest.php @@ -1,6 +1,8 @@ set('foo', 'bar'))->toBe('bar'); @@ -118,6 +120,16 @@ test('canonical url can be read from request', function () { ->toContain(''); }); +test('canonical url accepts origin', function () { + $this->get('/testing/5'); + + seo()->withUrl('https://foo.com'); + + expect(meta()) + ->toContain('') + ->toContain(''); +}); + test('canonical url can be changed', function () { seo()->withUrl(); From 7937fec988b9ca3c0c0214bc2be908d431fd457e Mon Sep 17 00:00:00 2001 From: Ben Bjurstrom Date: Wed, 4 Sep 2024 10:09:06 -0700 Subject: [PATCH 3/5] Run php-cs-fixer --- src/SEOManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SEOManager.php b/src/SEOManager.php index 706f2fb..1837d9d 100644 --- a/src/SEOManager.php +++ b/src/SEOManager.php @@ -226,9 +226,9 @@ class SEOManager /** Append canonical URL tags to the document head. */ public function withUrl(?string $origin = null): static { - if($origin){ + if ($origin) { $this->url(trim($origin, '/') . '/' . trim(request()->path(), '/')); - }else{ + } else { $this->url(request()->url()); } From ac434eaf03d9b8933e4510ca1efe15eaaeee2c94 Mon Sep 17 00:00:00 2001 From: Ben Bjurstrom Date: Fri, 22 Nov 2024 20:38:04 -0800 Subject: [PATCH 4/5] Update ManagerTest.php --- tests/Pest/ManagerTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Pest/ManagerTest.php b/tests/Pest/ManagerTest.php index 9c700f4..ea621f3 100644 --- a/tests/Pest/ManagerTest.php +++ b/tests/Pest/ManagerTest.php @@ -1,8 +1,6 @@ set('foo', 'bar'))->toBe('bar'); From 0b2ff24cac262afd7ed710bfd391c72b10f8a67b Mon Sep 17 00:00:00 2001 From: Ben Bjurstrom Date: Fri, 22 Nov 2024 21:04:31 -0800 Subject: [PATCH 5/5] Update ManagerTest.php --- tests/Pest/ManagerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Pest/ManagerTest.php b/tests/Pest/ManagerTest.php index 7b8dc3c..b041438 100644 --- a/tests/Pest/ManagerTest.php +++ b/tests/Pest/ManagerTest.php @@ -124,8 +124,8 @@ test('canonical url accepts origin', function () { seo()->withUrl('https://foo.com'); expect(meta()) - ->toContain('') - ->toContain(''); + ->toContain('') + ->toContain(''); }); test('canonical url can be changed', function () {