Skip to content

Commit 2822292

Browse files
committed
fix: support array with hreflang
1 parent 9654a8c commit 2822292

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

system/Helpers/html_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ function link_tag(
265265

266266
$link .= 'rel="' . $rel . '" ';
267267

268-
if ($type !== '' && $rel !== 'canonical') {
268+
if ($type !== '' && $rel !== 'canonical' && $hreflang === '') {
269269
$link .= 'type="' . $type . '" ';
270270
}
271271

tests/system/Helpers/HTMLHelperTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,18 @@ public function testLinkTagArray()
367367
$this->assertSame($expected, link_tag($parms));
368368
}
369369

370+
public function testLinkTagArrayHreflang()
371+
{
372+
$tag = link_tag([
373+
'href' => 'https://example.com/en',
374+
'rel' => 'alternate',
375+
'hreflang' => 'x-default',
376+
]);
377+
378+
$expected = '<link href="https://example.com/en" hreflang="x-default" rel="alternate" />';
379+
$this->assertSame($expected, $tag);
380+
}
381+
370382
public function testDocType()
371383
{
372384
$target = 'html4-strict';

0 commit comments

Comments
 (0)