Skip to content

Commit

Permalink
Fix http.request options to usesearch field in url.format
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Crabtree committed Feb 19, 2014
1 parent 814f485 commit 36098b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "sepia",
"author": "Avik Das <avik.das@berkeley.edu>",
"version": "1.0.1",
"version": "1.0.2",
"description": "A VCR-like module that records HTTP interactions and plays them back for speed and reliability",
"keywords": ["http", "testing"],
"keywords": [
"http",
"testing"
],
"homepage": "https://github.com/linkedin/sepia",
"bugs": "https://github.com/linkedin/sepia/issues",
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,17 @@ function constructFilename(method, reqUrl, reqBody, reqHeaders) {
// -- CONVENIENCE FUNCTIONS ----------------------------------------------------

function urlFromHttpRequestOptions(options, protocol) {
var parsedPath = options.path.split('?');
var pathname = parsedPath.shift();
var search = parsedPath.join('?');

var urlOptions = {
protocol: protocol,
hostname: options.hostname || options.host,
auth: options.auth,
port: options.port,
pathname: options.path
pathname: pathname,
search: search
};

return url.format(urlOptions);
Expand Down
10 changes: 10 additions & 0 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,16 @@ describe('utils.js', function() {
'https'
).should.equal('https://my-hostname/my/path');
});

it('parses ? properly"', function() {
urlFromHttpRequestOptions(
{
host: 'my-hostname',
path: '/my/path?foo=bar'
},
'https'
).should.equal('https://my-hostname/my/path?foo=bar');
});
});

describe('#shouldForceLive', function() {
Expand Down

0 comments on commit 36098b7

Please sign in to comment.