Skip to content

Commit bad8c5e

Browse files
Stankostereobooster
authored andcommitted
Add null check for link port (#384)
1 parent 05d7725 commit bad8c5e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/puppeteer_utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ const crawl = async opt => {
181181
// url.parse returns a string,
182182
// but options port is passed by a user and default value is a number
183183
// we are converting both to string to be sure
184-
const isOnAppPort = port.toString() === options.port.toString();
184+
// Port can be null, therefore we need the null check
185+
const isOnAppPort = port && port.toString() === options.port.toString();
185186

186187
if (hostname === "localhost" && isOnAppPort && !uniqueUrls.has(newUrl) && !streamClosed) {
187188
uniqueUrls.add(newUrl);

tests/examples/other/localhost-links-different-port.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
<body>
88
<a href="http://localhost:55555">localhost link on a different port</a>
9+
<a href="http://localhost">localhost link with no port</a>
910
</body>
1011

1112
</html>

0 commit comments

Comments
 (0)