Skip to content

Commit

Permalink
DevTools: sanitize audits filename before download
Browse files Browse the repository at this point in the history
BUG=GoogleChrome/lighthouse#5633

Change-Id: I58fc3d6541bfab6305936f5e5f5034b4bcfdaae1
Reviewed-on: https://chromium-review.googlesource.com/1132136
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Patrick Hulce <phulce@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#573937}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b9e6f065c035bfd0487695bd981cdf57108e5ceb
  • Loading branch information
patrickhulce authored and Commit Bot committed Jul 10, 2018
1 parent 36309ba commit 02a8c8a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions front_end/audits2/Audits2ReportSelector.js
Expand Up @@ -136,9 +136,10 @@ Audits2.ReportSelector.Item = class {
}

download() {
const url = new Common.ParsedURL(this._lighthouseResult.finalUrl).domain();
const domain = new Common.ParsedURL(this._lighthouseResult.finalUrl).domain();
const sanitizedDomain = domain.replace(/[^a-z0-9.-]+/gi, '_');
const timestamp = this._lighthouseResult.fetchTime;
const fileName = `${url}-${new Date(timestamp).toISO8601Compact()}.json`;
const fileName = `${sanitizedDomain}-${new Date(timestamp).toISO8601Compact()}.json`;
Workspace.fileManager.save(fileName, JSON.stringify(this._lighthouseResult), true);
}
};

0 comments on commit 02a8c8a

Please sign in to comment.