Skip to content

Commit

Permalink
Merge #15
Browse files Browse the repository at this point in the history
Resolve an issue with hreflang url attribute
  • Loading branch information
melbahja authored Sep 11, 2022
2 parents 0ef0a7c + cd129f9 commit 22b0b32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/MetaTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function hreflang(string $lang, string $url): MetaTags
{
return $this->push('link', [
'rel' => 'alternate',
'url' => $url,
'href' => $url,
'hreflang' => $lang,
]);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/MetaTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public function testMetaTags()
->mobile('https://m.example.com')
->canonical('https://example.com')
->shortlink('https://git.io/phpseo')
->amp('https://apm.example.com');
->amp('https://apm.example.com')
->hreflang('es-es', 'https://example.com/es/');

$this->assertNotEmpty((string) $metatags);

$this->assertEquals('<title>PHP SEO</title><meta name="title" content="PHP SEO" /><meta name="description" content="This is my description" /><meta name="author" content="Mohamed Elabhja" /><link href="https://m.example.com" rel="alternate" media="only screen and (max-width: 640px)" /><link rel="canonical" href="https://example.com" /><link rel="shortlink" href="https://git.io/phpseo" /><link rel="amphtml" href="https://apm.example.com" /><meta property="twitter:title" content="PHP SEO" /><meta property="twitter:description" content="This is my description" /><meta property="twitter:card" content="summary_large_image" /><meta property="twitter:image" content="https://avatars3.githubusercontent.com/u/8259014" /><meta property="og:title" content="PHP SEO" /><meta property="og:description" content="This is my description" /><meta property="og:image" content="https://avatars3.githubusercontent.com/u/8259014" />',
$this->assertEquals('<title>PHP SEO</title><meta name="title" content="PHP SEO" /><meta name="description" content="This is my description" /><meta name="author" content="Mohamed Elabhja" /><link href="https://m.example.com" rel="alternate" media="only screen and (max-width: 640px)" /><link rel="canonical" href="https://example.com" /><link rel="shortlink" href="https://git.io/phpseo" /><link rel="amphtml" href="https://apm.example.com" /><link rel="alternate" href="https://example.com/es/" hreflang="es-es" /><meta property="twitter:title" content="PHP SEO" /><meta property="twitter:description" content="This is my description" /><meta property="twitter:card" content="summary_large_image" /><meta property="twitter:image" content="https://avatars3.githubusercontent.com/u/8259014" /><meta property="og:title" content="PHP SEO" /><meta property="og:description" content="This is my description" /><meta property="og:image" content="https://avatars3.githubusercontent.com/u/8259014" />',
str_replace("\n", '', (string)$metatags)
);

Expand Down

0 comments on commit 22b0b32

Please sign in to comment.