diff --git a/src/Support/MetaTag.php b/src/Support/MetaTag.php
index 35ae356..1455309 100644
--- a/src/Support/MetaTag.php
+++ b/src/Support/MetaTag.php
@@ -2,13 +2,15 @@
namespace RalphJSmit\Laravel\SEO\Support;
+use Illuminate\Support\HtmlString;
+
class MetaTag extends Tag
{
public string $tag = 'meta';
public function __construct(
string $name,
- string $content,
+ string | HtmlString $content,
) {
$this->attributes['name'] = $name;
$this->attributes['content'] = $content;
diff --git a/src/Support/Tag.php b/src/Support/Tag.php
index 43f257d..e723080 100644
--- a/src/Support/Tag.php
+++ b/src/Support/Tag.php
@@ -40,7 +40,7 @@ public function render(): View
public function collectAttributes(): Collection
{
return collect($this->attributes)
- ->map(fn ($attribute) => trim($attribute))
+ ->map(fn (string | HtmlString $attribute) => is_string($attribute) ? trim($attribute) : $attribute)
->sortKeysUsing(function ($a, $b) {
$indexA = array_search($a, static::ATTRIBUTES_ORDER);
$indexB = array_search($b, static::ATTRIBUTES_ORDER);
diff --git a/src/TagManager.php b/src/TagManager.php
index b6edd46..16e1430 100644
--- a/src/TagManager.php
+++ b/src/TagManager.php
@@ -2,6 +2,8 @@
namespace RalphJSmit\Laravel\SEO;
+use const FILTER_VALIDATE_URL;
+
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
@@ -51,7 +53,7 @@ public function fillSEOData(?SEOData $SEOData = null): SEOData
}
}
- if ($SEOData->image && ! filter_var($SEOData->image, FILTER_VALIDATE_URL)) {
+ if ($SEOData->image && filter_var($SEOData->image, FILTER_VALIDATE_URL) === false) {
$SEOData->imageMeta();
$SEOData->image = secure_url($SEOData->image);
diff --git a/src/Tags/AuthorTag.php b/src/Tags/AuthorTag.php
index 666f823..d8ed2db 100644
--- a/src/Tags/AuthorTag.php
+++ b/src/Tags/AuthorTag.php
@@ -17,7 +17,7 @@ public static function initialize(?SEOData $SEOData): ?MetaTag
return new MetaTag(
name: 'author',
- content: trim($author)
+ content: $author
);
}
}
diff --git a/src/Tags/ImageTag.php b/src/Tags/ImageTag.php
index 554cded..c834546 100644
--- a/src/Tags/ImageTag.php
+++ b/src/Tags/ImageTag.php
@@ -2,6 +2,7 @@
namespace RalphJSmit\Laravel\SEO\Tags;
+use Illuminate\Support\HtmlString;
use RalphJSmit\Laravel\SEO\Support\MetaTag;
use RalphJSmit\Laravel\SEO\Support\SEOData;
@@ -17,7 +18,7 @@ public static function initialize(?SEOData $SEOData): ?MetaTag
return new MetaTag(
name: 'image',
- content: trim($image)
+ content: new HtmlString($image),
);
}
}
diff --git a/tests/Feature/Tags/ImageTagTest.php b/tests/Feature/Tags/ImageTagTest.php
index f0867b0..d9bee26 100644
--- a/tests/Feature/Tags/ImageTagTest.php
+++ b/tests/Feature/Tags/ImageTagTest.php
@@ -55,3 +55,14 @@
get(route('seo.test-page', ['page' => $page]))
->assertSee('', false);
});
+
+it('will not change query parameters on an image URL', function () {
+ $page = Page::create();
+
+ $page->seo->update([
+ 'image' => $url = 'https://website.test/images/xSVtl6ZF7fNuZIoXkZbzI2EzoAD.jpg?h=800&fit=contain&q=80&fm=webp',
+ ]);
+
+ get(route('seo.test-page', ['page' => $page]))
+ ->assertSee('', false);
+});