From 23cefde33513273a9c1bac06b0ecbb3e1b052b97 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 12 Dec 2017 11:04:44 -0500 Subject: [PATCH] code review: better importing from RP/NS --- src/js/user-rules.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/js/user-rules.js b/src/js/user-rules.js index ad7ee41..af3df6b 100644 --- a/src/js/user-rules.js +++ b/src/js/user-rules.js @@ -118,7 +118,7 @@ var processUserRules = function(response) { var fromRequestPolicy = function(content) { var matches = /\[origins-to-destinations\]([^\[]+)/.exec(content); if ( matches === null || matches.length !== 2 ) { - return ''; + return; } return matches[1].trim() .replace(/\|/g, ' ') @@ -143,7 +143,7 @@ var fromNoScript = function(content) { typeof noscript.whitelist !== 'string' || typeof noscript.V !== 'string' ) { - return ''; + return; } var out = {}; var reBad = /[a-z]+:\w*$/; @@ -176,12 +176,13 @@ var handleImportFilePicker = function() { return; } var result = fromRequestPolicy(this.result); - if ( result === '' ) { + if ( result === undefined ) { result = fromNoScript(this.result); - if ( result === '' ) { + if ( result === undefined ) { result = this.result; } } + if ( this.result === '' ) { return; } var request = { 'what': 'setUserRules', 'temporaryRules': rulesFromHTML('#diff .right li') + '\n' + result