Skip to content

Commit

Permalink
Fix url rendering in report
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Apr 10, 2018
1 parent e9f98d4 commit ab9137c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lighthouse-core/report/v2/renderer/details-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class DetailsRenderer {
let title;
try {
const parsed = Util.parseURL(url);
displayedPath = parsed.file;
displayedHost = parsed.hostname ? `(${parsed.hostname})` : '';
displayedPath = parsed.file === '/' ? parsed.origin :parsed.file;
displayedHost = parsed.file === '/' ? '' : `(${parsed.hostname})`;
title = url;
} catch (/** @type {!Error} */ e) {
if (!(e instanceof TypeError)) {
Expand Down
10 changes: 3 additions & 7 deletions lighthouse-core/report/v2/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,13 @@ class Util {
}

/**
* Split a URL into a file and hostname for easy display.
* Split a URL into a file, hostname and origin for easy display.
* @param {string} url
* @return {{file: string, hostname: string=}}
* @return {{file: string, hostname: string, origin: string}}
*/
static parseURL(url) {
const parsedUrl = new URL(url);
if (parsedUrl.pathname === '/') {
return {file: parsedUrl.origin};
} else {
return {file: Util.getURLDisplayName(parsedUrl), hostname: parsedUrl.hostname};
}
return {file: Util.getURLDisplayName(parsedUrl), hostname: parsedUrl.hostname, origin: parsedUrl.origin};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('DetailsRenderer', () => {

// Main request
assert.equal(chains.length, 4, 'generates correct number of chain nodes');
assert.equal(chains[0].querySelector('.crc-node__tree-hostname').textContent, '');
assert.equal(chains[0].querySelector('.crc-node__tree-hostname').textContent, '(example.com)');

// Children
assert.ok(chains[1].querySelector('.crc-node__tree-marker .vert-right'));
Expand Down

0 comments on commit ab9137c

Please sign in to comment.