Skip to content

Commit

Permalink
Merge pull request #57 from butschster/hotfix/53
Browse files Browse the repository at this point in the history
Fixes problem with generating link hreflang tag
  • Loading branch information
butschster authored Sep 10, 2023
2 parents 92ffaa1 + eb03bd3 commit 7decc9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MetaTags/Concerns/ManageLinksTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function setHrefLang(string $lang, string $url)
return $this->addLink('alternate_' . $lang, [
'rel' => 'alternate',
'hreflang' => $this->cleanString($lang),
'href' => $this->cleanString($url),
'href' => $url,
]);
}

Expand Down Expand Up @@ -129,4 +129,4 @@ public function addLink(string $name, array $attributes)

return $this->addTag($name, Tag::link($attributes));
}
}
}
11 changes: 11 additions & 0 deletions tests/MetaTags/HrefLangMetaTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ function test_hreflang_should_be_null_if_not_set()
$this->assertNull($this->makeMetaTags()->getHrefLang('en'));
}

function test_query_string()
{
$meta = $this->makeMetaTags()
->setHrefLang('zh-hans', 'https://example.com/?foo=bar&lang=zh-hans');

$this->assertHtmlableEquals(
'<link rel="alternate" hreflang="zh-hans" href="https://example.com/?foo=bar&lang=zh-hans">',
$meta->getHrefLang('zh-hans')
);
}

function test_convert_to_array()
{
$meta = $this->makeMetaTags()
Expand Down

0 comments on commit 7decc9e

Please sign in to comment.