Browse Source

code review: better importing from RP/NS

pull/2/head
Raymond Hill 7 years ago
parent
commit
23cefde335
No known key found for this signature in database GPG Key ID: 25E1490B761470C2
  1. 9
      src/js/user-rules.js

9
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

Loading…
Cancel
Save