diff --git a/packages/puppeteer-parse/index.js b/packages/puppeteer-parse/index.js index f84b5534a..26dc7eef2 100644 --- a/packages/puppeteer-parse/index.js +++ b/packages/puppeteer-parse/index.js @@ -402,13 +402,13 @@ function tryParseUrl(urlStr) { return null; } - // a regular expression to match URLs - var regex = /(https?:\/\/[^\s]+)/g; + // a regular expression to match all URLs + const regex = /(https?:\/\/[^\s]+)/g; - var match = regex.exec(urlStr); + const matches = urlStr.match(regex); - if (match) { - return match[1]; + if (matches) { + return matches[0]; // only return first match } else { return null; }