Skip to content

Commit

Permalink
Fix parsing invalid href
Browse files Browse the repository at this point in the history
  • Loading branch information
grandeljay committed Oct 10, 2022
1 parent f839fb1 commit d29a853
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vendor/embed/embed/src/Detectors/Languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace Embed\Detectors;

use function Embed\isEmpty;

class Languages extends Detector
{
/**
Expand All @@ -17,7 +19,7 @@ public function detect(): array
$language = $node->getAttribute('hreflang');
$href = $node->getAttribute('href');

if (!$language || !$href) {
if (isEmpty($language, $href)) {
continue;
}

Expand Down
22 changes: 22 additions & 0 deletions vendor/embed/embed/src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,25 @@ function getDirectory(string $path, int $position): ?string
$dirs = explode('/', $path);
return $dirs[$position + 1] ?? null;
}

/**
* Determine whether at least one of the supplied variables is empty.
*
* @param mixed ...$values The values to check.
*
* @return boolean
*/
function isEmpty(mixed ...$values): bool
{
$skipValues = array(
'undefined',
);

foreach ($values as $value) {
if (empty($value) || in_array($value, $skipValues)) {
return true;
}
}

return false;
}

0 comments on commit d29a853

Please sign in to comment.