Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent self-closing tag syntax #287

Merged
merged 1 commit into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CommomController extends Controller
OpenGraph::addImage($post->images->list('url'));
OpenGraph::addImage(['url' => 'http://image.url.com/cover.jpg', 'size' => 300]);
OpenGraph::addImage('http://image.url.com/cover.jpg', ['height' => 300, 'width' => 300]);

JsonLd::setTitle($post->title);
JsonLd::setDescription($post->resume);
JsonLd::setType('Article');
Expand Down Expand Up @@ -485,30 +485,30 @@ class CommomController extends Controller
<html>
<head>
<title>Title - Over 9000 Thousand!</title>
<meta name='description' itemprop='description' content='description...' />
<meta name='keywords' content='key1, key2, key3' />
<meta property='article:published_time' content='2015-01-31T20:30:11-02:00' />
<meta property='article:section' content='news' />

<meta property="og:description"content="description..." />
<meta property="og:title"content="Title" />
<meta property="og:url"content="http://current.url.com" />
<meta property="og:type"content="article" />
<meta property="og:locale"content="pt-br" />
<meta property="og:locale:alternate"content="pt-pt" />
<meta property="og:locale:alternate"content="en-us" />
<meta property="og:site_name"content="name" />
<meta property="og:image"content="http://image.url.com/cover.jpg" />
<meta property="og:image"content="http://image.url.com/img1.jpg" />
<meta property="og:image"content="http://image.url.com/img2.jpg" />
<meta property="og:image"content="http://image.url.com/img3.jpg" />
<meta property="og:image:url"content="http://image.url.com/cover.jpg" />
<meta property="og:image:size"content="300" />

<meta name="twitter:card"content="summary" />
<meta name="twitter:title"content="Title" />
<meta name="twitter:site"content="@LuizVinicius73" />
<meta name='description' itemprop='description' content='description...'>
<meta name='keywords' content='key1, key2, key3'>
<meta property='article:published_time' content='2015-01-31T20:30:11-02:00'>
<meta property='article:section' content='news'>

<meta property="og:description" content="description...">
<meta property="og:title" content="Title">
<meta property="og:url" content="http://current.url.com">
<meta property="og:type" content="article">
<meta property="og:locale" content="pt-br">
<meta property="og:locale:alternate" content="pt-pt">
<meta property="og:locale:alternate" content="en-us">
<meta property="og:site_name" content="name">
<meta property="og:image" content="http://image.url.com/cover.jpg">
<meta property="og:image" content="http://image.url.com/img1.jpg">
<meta property="og:image" content="http://image.url.com/img2.jpg">
<meta property="og:image" content="http://image.url.com/img3.jpg">
<meta property="og:image:url" content="http://image.url.com/cover.jpg">
<meta property="og:image:size" content="300">

<meta name="twitter:card"content="summary">
<meta name="twitter:title"content="Title">
<meta name="twitter:site"content="@LuizVinicius73">

<script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","name":"Title - Over 9000 Thousand!"}</script>
<!-- OR with multi -->
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Article","name":"Title - Over 9000 Thousand!"}</script>
Expand Down
2 changes: 1 addition & 1 deletion src/SEOTools/OpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected function eachProperties(
protected function makeTag($key = null, $value = null, $ogPrefix = false)
{
return sprintf(
'<meta property="%s%s" content="%s" />%s',
'<meta property="%s%s" content="%s">%s',
$ogPrefix ? $this->og_prefix : '',
strip_tags($key),
$this->cleanTagValue($value),
Expand Down
16 changes: 8 additions & 8 deletions src/SEOTools/SEOMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ public function generate($minify = false)
}

if (!empty($keywords)) {

if($keywords instanceof \Illuminate\Support\Collection){
$keywords = $keywords->toArray();
}

$keywords = implode(', ', $keywords);
$html[] = "<meta name=\"keywords\" content=\"{$keywords}\">";
}
Expand All @@ -182,23 +182,23 @@ public function generate($minify = false)
}

if ($canonical) {
$html[] = "<link rel=\"canonical\" href=\"{$canonical}\"/>";
$html[] = "<link rel=\"canonical\" href=\"{$canonical}\">";
}

if ($amphtml) {
$html[] = "<link rel=\"amphtml\" href=\"{$amphtml}\"/>";
$html[] = "<link rel=\"amphtml\" href=\"{$amphtml}\">";
}

if ($prev) {
$html[] = "<link rel=\"prev\" href=\"{$prev}\"/>";
$html[] = "<link rel=\"prev\" href=\"{$prev}\">";
}

if ($next) {
$html[] = "<link rel=\"next\" href=\"{$next}\"/>";
$html[] = "<link rel=\"next\" href=\"{$next}\">";
}

foreach ($languages as $lang) {
$html[] = "<link rel=\"alternate\" hreflang=\"{$lang['lang']}\" href=\"{$lang['url']}\"/>";
$html[] = "<link rel=\"alternate\" hreflang=\"{$lang['lang']}\" href=\"{$lang['url']}\">";
}

if ($robots) {
Expand All @@ -215,7 +215,7 @@ public function setTitle($title, $appendDefault = true)
{
// open redirect vulnerability fix
$title = str_replace(['http-equiv=', 'url='], '', $title);

// clean title
$title = strip_tags($title);

Expand Down
2 changes: 1 addition & 1 deletion src/SEOTools/TwitterCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function eachValue(array $values, $prefix = null)
private function makeTag($key, $value)
{
return sprintf(
'<meta name="%s" content="%s" />',
'<meta name="%s" content="%s">',
$this->prefix.strip_tags($key),
$this->cleanTagValue($value)
);
Expand Down
6 changes: 3 additions & 3 deletions tests/SEOTools/OpenGraphTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function test_set_title_and_description()
$this->openGraphs->setTitle('Hello, Ali');
$this->openGraphs->setDescription('This is a test by Ali.');

$expected = '<meta property="og:title" content="Hello, Ali" /><meta property="og:description" content="This is a test by Ali." />';
$expected = '<meta property="og:title" content="Hello, Ali"><meta property="og:description" content="This is a test by Ali.">';

$this->setRightAssertion($expected);

Expand All @@ -39,7 +39,7 @@ public function test_set_url()
{
$this->openGraphs->setUrl('https://www.domain.com');

$expected = '<meta property="og:title" content="Over 9000 Thousand!" /><meta property="og:description" content="For those who helped create the Genki Dama" /><meta content="https://www.domain.com" property="og:url">';
$expected = '<meta property="og:title" content="Over 9000 Thousand!"><meta property="og:description" content="For those who helped create the Genki Dama"><meta content="https://www.domain.com" property="og:url">';

$this->setRightAssertion($expected);

Expand All @@ -54,7 +54,7 @@ public function test_can_generate_tags_from_array()
"tag" => $tags,
]);

$expected = '<meta content="article" property="og:type"><meta property="og:title" content="Over 9000 Thousand!" /><meta property="og:description" content="For those who helped create the Genki Dama" /><meta property="article:tag" content="Example" /><meta property="article:tag" content="tags" /><meta property="article:tag" content="test" />';
$expected = '<meta content="article" property="og:type"><meta property="og:title" content="Over 9000 Thousand!"><meta property="og:description" content="For those who helped create the Genki Dama"><meta property="article:tag" content="Example"><meta property="article:tag" content="tags"><meta property="article:tag" content="test">';

$this->setRightAssertion($expected);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/SEOTools/SEOMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function test_set_canonical()
{
$fullHeader = "<title>It's Over 9000!</title>";
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
$fullHeader .= "<link rel=\"canonical\" href=\"http://domain.com\"/>";
$fullHeader .= "<link rel=\"canonical\" href=\"http://domain.com\">";
$canonical = 'http://domain.com';

$this->seoMeta->setCanonical($canonical);
Expand Down Expand Up @@ -216,7 +216,7 @@ public function test_set_amp()
{
$fullHeader = "<title>It's Over 9000!</title>";
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
$fullHeader .= "<link rel=\"amphtml\" href=\"http://domain.com/amp\"/>";
$fullHeader .= "<link rel=\"amphtml\" href=\"http://domain.com/amp\">";
$amphtml = 'http://domain.com/amp';

$this->seoMeta->setAmpHtml($amphtml);
Expand All @@ -229,7 +229,7 @@ public function test_set_next()
{
$fullHeader = "<title>It's Over 9000!</title>";
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
$fullHeader .= "<link rel=\"next\" href=\"http://domain.com\"/>";
$fullHeader .= "<link rel=\"next\" href=\"http://domain.com\">";
$next = 'http://domain.com';

$this->seoMeta->setNext($next);
Expand All @@ -242,7 +242,7 @@ public function test_set_prev()
{
$fullHeader = "<title>It's Over 9000!</title>";
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
$fullHeader .= "<link rel=\"prev\" href=\"http://domain.com\"/>";
$fullHeader .= "<link rel=\"prev\" href=\"http://domain.com\">";
$prev = 'http://domain.com';

$this->seoMeta->setPrev($prev);
Expand All @@ -255,7 +255,7 @@ public function test_set_alternate_languages()
{
$fullHeader = "<title>It's Over 9000!</title>";
$fullHeader .= "<meta name=\"description\" content=\"For those who helped create the Genki Dama\">";
$fullHeader .= "<link rel=\"alternate\" hreflang=\"en\" href=\"http://domain.com\"/>";
$fullHeader .= "<link rel=\"alternate\" hreflang=\"en\" href=\"http://domain.com\">";
$lang = 'en';
$langUrl = 'http://domain.com';

Expand Down
32 changes: 16 additions & 16 deletions tests/SEOTools/SEOToolsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function test_set_title()

$expected = "<title>Kamehamehaaaaaaa - It's Over 9000!</title>";
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
$expected .= '<meta property="og:title" content="Kamehamehaaaaaaa" />';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
$expected .= '<meta name="twitter:title" content="Kamehamehaaaaaaa" />';
$expected .= '<meta property="og:title" content="Kamehamehaaaaaaa">';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
$expected .= '<meta name="twitter:title" content="Kamehamehaaaaaaa">';
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Kamehamehaaaaaaa","description":"For those who helped create the Genki Dama"}</script>';

$this->assertEquals('Kamehamehaaaaaaa - It\'s Over 9000!', $this->seoTools->getTitle());
Expand All @@ -63,9 +63,9 @@ public function test_set_description()

$expected = "<title>It's Over 9000!</title>";
$expected .= '<meta name="description" content="Kamehamehaaaaaaa">';
$expected .= '<meta property="og:description" content="Kamehamehaaaaaaa" />';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
$expected .= '<meta name="twitter:description" content="Kamehamehaaaaaaa" />';
$expected .= '<meta property="og:description" content="Kamehamehaaaaaaa">';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
$expected .= '<meta name="twitter:description" content="Kamehamehaaaaaaa">';
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"Kamehamehaaaaaaa"}</script>';


Expand All @@ -78,9 +78,9 @@ public function test_set_canonical()

$expected = "<title>It's Over 9000!</title>";
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
$expected .= '<link rel="canonical" href="http://domain.com"/>';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
$expected .= '<link rel="canonical" href="http://domain.com">';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"For those who helped create the Genki Dama"}</script>';

$this->setRightAssertion($expected);
Expand All @@ -93,11 +93,11 @@ public function test_add_images()

$expected = "<title>It's Over 9000!</title>";
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png" />';
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png" />';
$expected .= '<meta name="twitter:image" content="Kamehamehaaaaaaa.png" />';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png">';
$expected .= '<meta property="og:image" content="Kamehamehaaaaaaa.png">';
$expected .= '<meta name="twitter:image" content="Kamehamehaaaaaaa.png">';
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"For those who helped create the Genki Dama","image":["Kamehamehaaaaaaa.png","Kamehamehaaaaaaa.png"]}</script>';

$this->setRightAssertion($expected);
Expand All @@ -107,8 +107,8 @@ public function test_generate()
{
$expected = "<title>It's Over 9000!</title>";
$expected .= '<meta name="description" content="For those who helped create the Genki Dama">';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!" />';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama" />';
$expected .= '<meta property="og:title" content="Over 9000 Thousand!">';
$expected .= '<meta property="og:description" content="For those who helped create the Genki Dama">';
$expected .= '<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Over 9000 Thousand!","description":"For those who helped create the Genki Dama"}</script>';

$this->setRightAssertion($expected);
Expand Down
18 changes: 9 additions & 9 deletions tests/SEOTools/TwitterCardsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function test_set_title()
{
$this->twitterCards->setTitle('Kamehamehaaaaaaaa');

$expected = '<meta name="twitter:title" content="Kamehamehaaaaaaaa" />';
$expected = '<meta name="twitter:title" content="Kamehamehaaaaaaaa">';

$this->setRightAssertion($expected);
}
Expand All @@ -37,7 +37,7 @@ public function test_set_site()
{
$this->twitterCards->setSite('http://kakaroto.9000');

$expected = '<meta name="twitter:site" content="http://kakaroto.9000" />';
$expected = '<meta name="twitter:site" content="http://kakaroto.9000">';

$this->setRightAssertion($expected);
}
Expand All @@ -46,7 +46,7 @@ public function test_set_url()
{
$this->twitterCards->setUrl('http://kakaroto.9000');

$expected = '<meta name="twitter:url" content="http://kakaroto.9000" />';
$expected = '<meta name="twitter:url" content="http://kakaroto.9000">';

$this->setRightAssertion($expected);
}
Expand All @@ -55,7 +55,7 @@ public function test_set_description()
{
$this->twitterCards->setDescription('Kamehamehaaaaaaaa');

$expected = '<meta name="twitter:description" content="Kamehamehaaaaaaaa" />';
$expected = '<meta name="twitter:description" content="Kamehamehaaaaaaaa">';

$this->setRightAssertion($expected);
}
Expand All @@ -66,7 +66,7 @@ public function test_cleans_description()

$this->twitterCards->setDescription($description);

$expected = '<meta name="twitter:description" content="&quot;Foo bar&quot; -&gt; abc" />';
$expected = '<meta name="twitter:description" content="&quot;Foo bar&quot; -&gt; abc">';

$this->setRightAssertion($expected);
}
Expand All @@ -75,7 +75,7 @@ public function test_set_type()
{
$this->twitterCards->setType('sayajin');

$expected = '<meta name="twitter:card" content="sayajin" />';
$expected = '<meta name="twitter:card" content="sayajin">';

$this->setRightAssertion($expected);
}
Expand All @@ -84,8 +84,8 @@ public function test_set_images()
{
$this->twitterCards->setImages(['sayajin.png', 'namekusei.png']);

$expected = "<meta name=\"twitter:images0\" content=\"sayajin.png\" />";
$expected .= "<meta name=\"twitter:images1\" content=\"namekusei.png\" />";
$expected = "<meta name=\"twitter:images0\" content=\"sayajin.png\">";
$expected .= "<meta name=\"twitter:images1\" content=\"namekusei.png\">";

$this->setRightAssertion($expected);
}
Expand All @@ -94,7 +94,7 @@ public function test_set_image()
{
$this->twitterCards->setImage('sayajin.png');

$expected = "<meta name=\"twitter:image\" content=\"sayajin.png\" />";
$expected = "<meta name=\"twitter:image\" content=\"sayajin.png\">";

$this->setRightAssertion($expected);
}
Expand Down