Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass search params as part of path string #40

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/request.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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