Skip to content

Commit

Permalink
Add null check for link port (stereobooster#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanko authored and stereobooster committed May 31, 2019
1 parent 05d7725 commit bad8c5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/puppeteer_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ const crawl = async opt => {
// url.parse returns a string,
// but options port is passed by a user and default value is a number
// we are converting both to string to be sure
const isOnAppPort = port.toString() === options.port.toString();
// Port can be null, therefore we need the null check
const isOnAppPort = port && port.toString() === options.port.toString();

if (hostname === "localhost" && isOnAppPort && !uniqueUrls.has(newUrl) && !streamClosed) {
uniqueUrls.add(newUrl);
Expand Down
1 change: 1 addition & 0 deletions tests/examples/other/localhost-links-different-port.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<body>
<a href="http://localhost:55555">localhost link on a different port</a>
<a href="http://localhost">localhost link with no port</a>
</body>

</html>

0 comments on commit bad8c5e

Please sign in to comment.