From 50019f39e997386a67f4872946250b1537c8381a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 11 Nov 2016 09:22:45 -0800 Subject: [PATCH] :art: --- lib/browser/guest-window-manager.js | 9 ++++----- spec/api-browser-window-spec.js | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index 3240161..d7d169f 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -120,14 +120,13 @@ const createGuest = function (embedder, url, frameName, options, postData) { // The above code would not work if a navigation to "about:blank" is done // here, since the window would be cleared of all changes in the next tick. const loadOptions = {} - if (postData) { + if (postData != null) { loadOptions.postData = postData loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded' - if (postData.length) { + if (postData.length > 0) { const postDataFront = postData[0].bytes.toString() - const regex = new RegExp(/^--.*[^-\r\n]/) - const boundary = regex.exec(postDataFront) - if (boundary) { + const boundary = /^--.*[^-\r\n]/.exec(postDataFront) + if (boundary != null) { loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}` } } diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index c7a404f..1214e08 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -29,15 +29,15 @@ describe('browser-window module', function () { const fileStats = fs.statSync(filePath) postData = [ { - 'type': 'rawData', - 'bytes': new Buffer('username=test&file=') + type: 'rawData', + bytes: new Buffer('username=test&file=') }, { - 'type': 'file', - 'filePath': filePath, - 'offset': 0, - 'length': fileStats.size, - 'modificationTime': fileStats.mtime.getTime() / 1000 + type: 'file', + filePath: filePath, + offset: 0, + length: fileStats.size, + modificationTime: fileStats.mtime.getTime() / 1000 } ] server = http.createServer(function (req, res) { -- 2.7.4