Skip to content

Commit

Permalink
fix: pass search params as part of path string (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf committed Mar 2, 2022
1 parent a6e682b commit 404ad4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/request.js
Expand Up @@ -238,7 +238,7 @@ class Request extends Body {
: '',
host: parsedURL.host,
hostname: parsedURL.hostname,
path: parsedURL.pathname,
path: `${parsedURL.pathname}${parsedURL.search}`,
port: parsedURL.port,
protocol: parsedURL.protocol,
}
Expand Down
9 changes: 9 additions & 0 deletions test/request.js
Expand Up @@ -398,6 +398,15 @@ t.test('get node request options', t => {
family: 6,
})

t.test('passes through search params', (t) => {
const req = new Request('http://x.y?one=two&three=four')
const options = Request.getNodeRequestOptions(req)
t.match(options, {
path: '/?one=two&three=four',
})
t.end()
})

t.test('function as agent', t => {
let agentCalled = false
const agent = () => {
Expand Down

0 comments on commit 404ad4c

Please sign in to comment.