Skip to content

Commit

Permalink
fixed broken generic handler. whoops. that's why I need to get an
Browse files Browse the repository at this point in the history
automated test suite for this.
  • Loading branch information
michaelficarra committed Mar 14, 2011
1 parent 255db75 commit d0b43ac
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions handlers/generic.js
@@ -1,5 +1,6 @@
(function(){

// only load generic handler if no specific handler exists
if(chrome.extension.onRequest.hasListeners()) return;

var getInfoHash = function(){
Expand All @@ -11,13 +12,16 @@
};

chrome.extension.onRequest.addListener(function(request,sender,respond){
if(request.type != 'info_hash') return respond(null);
respond(getInfoHash());
});

chrome.extension.onRequest.addListener(function(request,sender,respond){
if(request.type != 'hasMagnet') return respond(null);
respond(getInfoHash() != null);
switch(request.type){
case 'info_hash':
respond(getInfoHash());
break;
case 'hasMagnet':
respond(getInfoHash() != null);
break;
default:
respond(null);
}
});

})()

0 comments on commit d0b43ac

Please sign in to comment.