Skip to content

Commit

Permalink
prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Aug 23, 2017
1 parent 0ba7a77 commit b861152
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

All notable changes to `mixed-content-scanner` will be documented in this file

## 1.1.1 - 2017-08-23

- do not mark shortlinks as mixed content

## 1.1.0 - 2017-08-11

- add `toArray` to `MixedContent`
Expand Down
19 changes: 12 additions & 7 deletions src/MixedContentExtractor.php
Expand Up @@ -16,13 +16,7 @@ public static function extract(string $html, string $currentUri): array
return (new DomCrawler($html, $currentUri))
->filterXPath("//{$tagName}[@{$attribute}]")
->reduce(function (DomCrawler $node) {
$relAttr = $node->getNode(0)->attributes->getNamedItem('rel');

if ($relAttr !== null && strtolower($relAttr->nodeValue) === 'shortlink') {
return false;
}

return true;
return ! self::isShortLink($node);
})
->each(function (DomCrawler $node) use ($tagName, $attribute) {
$url = Url::create($node->attr($attribute));
Expand Down Expand Up @@ -56,4 +50,15 @@ protected static function getSearchNodes(): Collection
['video', 'src'],
]);
}

protected static function isShortLink(DomCrawler $node)
{
$relAttribute = $node->getNode(0)->attributes->getNamedItem('rel');

if (is_null($relAttribute)) {
return false;
}

return strtolower($relAttribute->nodeValue) === 'shortlink';
}
}

0 comments on commit b861152

Please sign in to comment.