Skip to content

Commit

Permalink
fix bugs when installed in Laravel projects
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Mar 1, 2018
1 parent 2db1765 commit 4aeae8b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

All notable changes to `spatie/crawler` will be documented in this file.

## 4.0.0 - 2018-XX-XX
## 4.0.1 - 2018-03-01

- fix bugs when installed in Laravel projects

## 4.0.0 - 2018-03-01

- the `CrawlObserver` and `CrawlProfile` are upgraded from interfaces to abstract classes
- don't crawl `tel:` links
Expand Down
4 changes: 2 additions & 2 deletions src/CrawlQueue/CollectionCrawlQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class CollectionCrawlQueue implements CrawlQueue

public function __construct()
{
$this->urls = collect();
$this->urls = new Collection();

$this->pendingUrls = collect();
$this->pendingUrls = new Collection();
}

public function add(CrawlUrl $url): CrawlQueue
Expand Down
4 changes: 2 additions & 2 deletions src/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected function addAllLinksToCrawlQueue(string $html, UriInterface $foundOnUr
{
$allLinks = $this->extractAllLinks($html, $foundOnUrl);

collect($allLinks)
(new Collection($allLinks))
->filter(function (UriInterface $url) {
return $this->hasCrawlableScheme($url);
})
Expand Down Expand Up @@ -408,7 +408,7 @@ protected function extractAllLinks(string $html, UriInterface $foundOnUrl): Coll

$domCrawler = new DomCrawler($html, $foundOnUrl);

return collect($domCrawler->filterXpath('//a')->links())
return (new Collection($domCrawler->filterXpath('//a')->links()))
->map(function (Link $link) {
try {
return new Uri($link->getUri());
Expand Down

0 comments on commit 4aeae8b

Please sign in to comment.