1
0
Fork 0
mirror of https://github.com/archtechx/laravel-seo.git synced 2025-12-12 01:44:03 +00:00

only add prefix when not already available

This commit is contained in:
tpetry 2022-07-05 20:17:25 +02:00
parent 5c2fa1753a
commit 96c20f3bf6
2 changed files with 6 additions and 6 deletions

View file

@ -196,11 +196,11 @@ class SEOManager
'previewify:description' => $this->raw('description'), 'previewify:description' => $this->raw('description'),
]; ];
} else { } else {
$data = array_combine( $data = array_combine(
array_map(fn ($key) => "previewify:{$key}", array_keys($data)), array_map(fn ($key) => str_starts_with($key, 'previewify:') ? $key : "previewify:{$key}", array_keys($data)),
$data, $data,
); );
} }
$query = base64_encode(json_encode($data, JSON_THROW_ON_ERROR)); $query = base64_encode(json_encode($data, JSON_THROW_ON_ERROR));

View file

@ -18,7 +18,7 @@ test('previewify makes a request to the template not the alias', function () {
test('previewify templates can be given data', function () { test('previewify templates can be given data', function () {
seo()->previewify('blog', 1); seo()->previewify('blog', 1);
expect(seo()->previewify('blog', ['title' => 'abc', 'excerpt' => 'def'])) expect(seo()->previewify('blog', ['title' => 'abc', 'previewify:excerpt' => 'def']))
->toContain('previewify.app/generate/templates/1') ->toContain('previewify.app/generate/templates/1')
->toContain(base64_encode(json_encode(['previewify:title' => 'abc', 'previewify:excerpt' => 'def']))); ->toContain(base64_encode(json_encode(['previewify:title' => 'abc', 'previewify:excerpt' => 'def'])));
}); });