[DomCrawler] Improve the sprintf() call in selectLink()

This commit is contained in:
Kévin Dunglas 2018-03-11 10:04:59 +01:00
parent 009b4d216e
commit e2ab1a47d2
No known key found for this signature in database
GPG Key ID: 4D04EBEF06AAF3A6

View File

@ -710,10 +710,9 @@ class Crawler implements \Countable, \IteratorAggregate
*/
public function selectLink($value)
{
$xpath = sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) ', static::xpathLiteral(' '.$value.' ')).
sprintf('or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)]]', static::xpathLiteral(' '.$value.' '));
return $this->filterRelativeXPath($xpath);
return $this->filterRelativeXPath(
sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %1$s) or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %1$s)]]', static::xpathLiteral(' '.$value.' '))
);
}
/**