Skip to content

Commit

Permalink
Fix crash on bad crawl (where url is null for some reason)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesAU committed Mar 28, 2017
1 parent 06231e6 commit 1191635
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/Crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class Crawler {
Array.from(document.querySelectorAll(`${tagName}[${urlAttribute}]`)).forEach(element => {
const { protocol, host, path } = url.parse(element.getAttribute(urlAttribute))
if (protocol || host) return
if (!path) return;
const relativePath = url.resolve(currentPath, path)
if (!this.processed[relativePath]) this.paths.push(relativePath)
})
Expand Down

4 comments on commit 1191635

@JustinINevill
Copy link

@JustinINevill JustinINevill commented on 1191635 Apr 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resolved the issue for me where <a href="https://..."> tags were causing the following errors:

TypeError: Parameter "url" must be a string, not object
    at Url.parse (url.js:88:11)
    at urlParse (url.js:82:5)
    at Url.resolve (url.js:642:29)
    at Object.urlResolve [as resolve] (url.js:638:40)
    at /node_modules/react-snapshot/lib/Crawler.js:96:44
    at Array.forEach (native)
    at /node_modules/react-snapshot/lib/Crawler.js:88:83
    at Array.forEach (native)
    at Crawler.extractNewLinks (/node_modules/react-snapshot/lib/Crawler.js:86:36)
    at /node_modules/react-snapshot/lib/Crawler.js:68:15

@cezarneaga
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is awesome. can you make a pull request with this. i do not see a reason why it shouldn't be in the npm package :)

@TeeKoo
Copy link

@TeeKoo TeeKoo commented on 1191635 May 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Is there a new version going to be published for NPM too? Currently the bug still exists in 1.0.4.

@JulesAU
Copy link
Owner Author

@JulesAU JulesAU commented on 1191635 May 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me like this fixed it, no?

Please sign in to comment.