diff --git a/lighthouse-core/lib/url-shim.js b/lighthouse-core/lib/url-shim.js index 9fd6512a3cce..644daee51f69 100644 --- a/lighthouse-core/lib/url-shim.js +++ b/lighthouse-core/lib/url-shim.js @@ -97,12 +97,12 @@ class URLShim extends URL { const urlAInfo = new URL(urlA); const urlBInfo = new URL(urlB); - if (!urlAInfo.host || !urlBInfo.host) { + if (!urlAInfo.hostname || !urlBInfo.hostname) { return false; } - const urlARootDomain = urlAInfo.host.split('.').slice(-2).join('.'); - const urlBRootDomain = urlBInfo.host.split('.').slice(-2).join('.'); + const urlARootDomain = urlAInfo.hostname.split('.').slice(-2).join('.'); + const urlBRootDomain = urlBInfo.hostname.split('.').slice(-2).join('.'); return urlARootDomain === urlBRootDomain; } diff --git a/lighthouse-core/test/audits/uses-rel-preload-test.js b/lighthouse-core/test/audits/uses-rel-preload-test.js index 8790281fb630..81417842d010 100644 --- a/lighthouse-core/test/audits/uses-rel-preload-test.js +++ b/lighthouse-core/test/audits/uses-rel-preload-test.js @@ -50,7 +50,7 @@ describe('Performance: uses-rel-preload audit', () => { it('should suggest preload resource', () => { const rootNode = buildNode(1, 'http://example.com'); - const mainDocumentNode = buildNode(2, 'http://www.example.com'); + const mainDocumentNode = buildNode(2, 'http://www.example.com:3000'); const scriptNode = buildNode(3, 'http://www.example.com/script.js'); const scriptAddedNode = buildNode(4, 'http://www.example.com/script-added.js'); const scriptSubNode = buildNode(5, 'http://sub.example.com/script-sub.js'); @@ -101,14 +101,14 @@ describe('Performance: uses-rel-preload audit', () => { }; const mainResource = Object.assign({}, defaultMainResource, { - url: 'http://www.example.com', + url: 'http://www.example.com:3000', redirects: [''], }); const networkRecords = [ { requestId: '2', _isLinkPreload: false, - url: 'http://www.example.com', + url: 'http://www.example.com:3000', }, { requestId: '3',