Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthropohedron committed Apr 5, 2015
1 parent 0f7887a commit 69fcdee
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ function AbstractPattern(apply) {
}
}
AbstractPattern.prototype = {
testRequest: function defaultTestRequest() { return false; },
testResponse: function defaultTestResponse() { return false; }
testURI: function defaultTestURI() { return false; },
testRequest: function defaultTestRequest(req) {
return this.testURI(req.URI);
},
testResponse: function defaultTestResponse(resp) {
return this.testURI(resp.URI);
}
};

function TagPattern(pattern) {
Expand Down Expand Up @@ -77,12 +82,6 @@ function HostPattern(pattern) {
HostPattern.prototype = new AbstractPattern({
testURI: function testURI(uri) {
return this.hostRE.test(uri.host);
},
testRequest: function testRequest(req) {
return this.testURI(req.URI);
},
testResponse: function testResponse(resp) {
return this.testURI(resp.URI);
}
});

Expand All @@ -102,12 +101,6 @@ function PathPattern(pattern) {
PathPattern.prototype = new AbstractPattern({
testURI: function testURI(uri) {
return this.hostRE.test(uri.host) && this.pathRE.test(uri.path);
},
testRequest: function testRequest(req) {
return this.testURI(req.URI);
},
testResponse: function testResponse(resp) {
return this.testURI(resp.URI);
}
});

Expand Down

0 comments on commit 69fcdee

Please sign in to comment.