diff options
Diffstat (limited to 'lib/js_checker/js_checker.js')
-rw-r--r-- | lib/js_checker/js_checker.js | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/lib/js_checker/js_checker.js b/lib/js_checker/js_checker.js index da3ebe6..21bfeaf 100644 --- a/lib/js_checker/js_checker.js +++ b/lib/js_checker/js_checker.js @@ -161,6 +161,7 @@ JsChecker.prototype.isFreeLicensed = function(script) { * Takes in some javascript code (as string). * Uses Narcissus parser to build an abstract syntax tree. * Checks for trivialness. + * */ JsChecker.prototype.searchJs = function(jsCode, resultReady, url) { var that = this; @@ -203,39 +204,20 @@ JsChecker.prototype.searchJs = function(jsCode, resultReady, url) { this.freeToken = types.emptyTypeObj(); this.nontrivialness = types.emptyTypeObj(); - if (typeof url === 'undefined' || url === null) { - // use this.hash to keep track of comments made by the nontrivial - // checker code about why/how the code is found to be nontrivial. - this.nonTrivialChecker = - nonTrivialModule.nonTrivialChecker(this.hash); - - // register callback and hash. So that result - // can be passed. - setHashCallback( - this.hash, this.handleTree.bind(this), this.notification); - - // parse using ChromeWorker. - console.debug( - 'JsChecker.searchJs(): starting narcissusWorker.parse()'); - narcissusWorker.parse(this.jsCode, this.hash); - } else { - // Handle external scripts - console.debug('Analyzing external script: ' + url); - this.parseTree = {}; - if (this.isFreeLicensed(this.jsCode)) { - this.parseTree.freeTrivialCheck = type.trivialWithComment( - 'This script is under free software licenses: ' + url); - } else { - this.parseTree.freeTrivialCheck = type.nontrivialWithComment( - 'This external script is not under free software ' + - 'licenses: ' + url); - } + // use this.hash to keep track of comments made by the nontrivial + // checker code about why/how the code is found to be nontrivial. + this.nonTrivialChecker = + nonTrivialModule.nonTrivialChecker(this.hash); - // Cache result with hash of script for future checks - scriptsCached.addEntry( - this.jsCode, this.parseTree.freeTrivialCheck, - this.relationChecker, true, this.url); - } + // register callback and hash. So that result + // can be passed. + setHashCallback( + this.hash, this.handleTree.bind(this), this.notification); + + // parse using ChromeWorker. + console.debug( + 'JsChecker.searchJs(): starting narcissusWorker.parse()'); + narcissusWorker.parse(this.jsCode, this.hash); } catch (x) { console.debug('error', x); this.handleTree(false, x); |