Skip to content

Commit

Permalink
ensure correct relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Dec 20, 2020
1 parent 76a58c3 commit 566e104
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ public function run(RequestResponse $requestResponse, Crawler $crawler)
foreach ($crawler->getParsers() as $parser) {
if ($parser->validateRequestResponse($requestResponse)) {
$parserResult = $parser->run($this, $requestResponse);

foreach ($parserResult->links as $url => $linkTitle) {
// create new url object for all found urls
$url = new Url($url);
$url->merge($crawler->baseUrl);

// merge the current url (which is equals to the referrer in this case)
// in order to ensure correct relative paths
$url->merge($this->url);
if ($url->isValid() && $crawler->baseUrl->sameHost($url)) {
$job = new Job($url, $this->url);
$crawler->push($job);
Expand Down

0 comments on commit 566e104

Please sign in to comment.