Skip to content

Commit

Permalink
Properly use file name provided through triggerExport API
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed Apr 23, 2015
1 parent 6d48ae3 commit 2272fac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/net/export/export-driver-actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function ExportDriverApi(actor) {
actor.conn.send({
from: actor.actorID,
type: "triggerExport",
fileName: options.fileName + "",
fileName: options.fileName,
});
};

Expand Down
12 changes: 8 additions & 4 deletions lib/net/export/network-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,21 @@ const NetworkMonitor = Class(

// Support for custom file names
var defaultFileName = Options.get("netexport.defaultFileName");

// A file name can be provided through NetExport.triggerExport() API
if (fileNameFromContent) {
defaultFileName = fileNameFromContent;
}

if (defaultFileName) {
// Read more about toLocaleFormat & format string.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat
var name = now.toLocaleFormat(defaultFileName);
name = name.replace(/\:/gm, "-", "");
name = name.replace(/\//gm, "_", "");
fileName = name;
}

if (fileNameFromContent) {
fileName = fileNameFromContent;
}

// Default file extension is zip if compressing is on
let fileExt = jsonp ? ".harp" : ".har";
if (Options.get("netexport.compress")) {
Expand Down

0 comments on commit 2272fac

Please sign in to comment.