-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from Westwing-Home-and-Living/mod_uri
Simple request URI modification logic
- Loading branch information
Showing
3 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var needle = require('../'), | ||
sinon = require('sinon'), | ||
should = require('should'), | ||
http = require('http'), | ||
helpers = require('./helpers'); | ||
|
||
var port = 3456; | ||
|
||
describe('uri_modifier config parameter function', function() { | ||
|
||
var server, uri; | ||
|
||
function send_request(mw, cb) { | ||
return needle.get(uri, null, { uri_modifier: mw }, cb); | ||
} | ||
|
||
before(function(done){ | ||
server = helpers.server({ port: port }, done); | ||
}) | ||
|
||
after(function(done) { | ||
server.close(done); | ||
}) | ||
|
||
describe('modifies uri', function(){ | ||
|
||
var path = '/foo/replace'; | ||
|
||
before(function() { | ||
uri = 'localhost:' + port + path | ||
}); | ||
|
||
it('should modify path', function(done) { | ||
send_request(function(uri) { | ||
return uri.replace('/replace', ''); | ||
}, function(err, res) { | ||
should.not.exist(err); | ||
should(res.req.path).be.exactly('/foo'); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
}) | ||
|
||
}) |