bugfix inverted logic
This commit is contained in:
parent
c81551e2bf
commit
d81dc86381
@ -53,18 +53,20 @@ class CrawlObserver extends \Spatie\Crawler\CrawlObserver
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($fullRedirectReport as $rr){
|
foreach($fullRedirectReport as $rr){
|
||||||
$this->results[(String)$rr['location']]=[
|
$this->addResult(
|
||||||
'code'=>$rr['code'],
|
(String)$rr['location'],
|
||||||
'type'=>$response->getHeader('Content-Type')[0]??null,
|
(string)$foundOnUrl,
|
||||||
'foundOn'=>[(string)$foundOnUrl],
|
$rr['code'],
|
||||||
];
|
$response->getHeader('Content-Type')[0]??null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->results[(String)$url]=[
|
$this->addResult(
|
||||||
'code'=>$response->getStatusCode(),
|
(String)$url,
|
||||||
'type'=>$response->getHeader('Content-Type')[0]??null,
|
(string)$foundOnUrl,
|
||||||
'foundOn'=>[(string)$foundOnUrl],
|
$response->getStatusCode(),
|
||||||
];
|
$response->getHeader('Content-Type')[0]??null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ class CrawlObserver extends \Spatie\Crawler\CrawlObserver
|
|||||||
UriInterface $url,
|
UriInterface $url,
|
||||||
?UriInterface $foundOnUrl = null
|
?UriInterface $foundOnUrl = null
|
||||||
){
|
){
|
||||||
$this->results[(String)$url]['foundOn'][]=(string)$foundOnUrl;
|
$this->addResult((String)$url,(string)$foundOnUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,11 +100,23 @@ class CrawlObserver extends \Spatie\Crawler\CrawlObserver
|
|||||||
if( $response=$requestException->getResponse() ){
|
if( $response=$requestException->getResponse() ){
|
||||||
$this->crawled($url,$response,$foundOnUrl);
|
$this->crawled($url,$response,$foundOnUrl);
|
||||||
}else{
|
}else{
|
||||||
$this->results[(String)$url]=[
|
$this->addResult((String)$url,(string)$foundOnUrl);
|
||||||
'code'=>'???',
|
}
|
||||||
'type'=>'???',
|
}
|
||||||
'foundOn'=>[(string)$foundOnUrl],
|
|
||||||
|
public function addResult($url, $foundOn, $code='???', $type='???'){
|
||||||
|
if(!isset($this->results[$url])){
|
||||||
|
$this->results[$url]=[
|
||||||
|
'code'=>$code,
|
||||||
|
'type'=>$type,
|
||||||
|
'foundOn'=>[$foundOn=>1],
|
||||||
];
|
];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(isset($this->results[$url]['foundOn'][$foundOn])){
|
||||||
|
$this->results[$url]['foundOn'][$foundOn]++;
|
||||||
|
}else{
|
||||||
|
$this->results[$url]['foundOn'][$foundOn]=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user