Skip to content
This repository was archived by the owner on Apr 27, 2021. It is now read-only.

Commit 85041b0

Browse files
committed
Update tests + Fix query params with raw HTTP Node server
1 parent cbdfbd6 commit 85041b0

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# ChangeLog
22

3-
## Unreleased
3+
## 1.0.5
44

5-
...
5+
- Refresh packages
6+
- Fix query params with Node HTTP API server
67

7-
## 1.0.0 - 2018-03-02
8-
9-
### Added
8+
## 1.0.4
109

1110
- Initial release

src/RedirectionIO.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class RedirectionIO {
4040
}
4141

4242
const scheme = req.headers['x-forwarded-proto'] ? req.headers['x-forwarded-proto'] : 'http'
43-
const request = new Request(req.headers['host'], req.url.split('?')[0], req.headers['user-agent'], scheme)
43+
const request = new Request(req.headers['host'], req.url, req.headers['user-agent'], scheme)
4444
const response = await this.handleRequest(request)
4545

4646
req.rio = { request: request, response: response }

src/Resources/fake_rules.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
["/baz", "/qux", 302],
44
["/quux", "/corge", 307],
55
["/uier", "/grault", 308],
6-
["/garply", "", 410]
6+
["/garply", "", 410],
7+
["/foo?with=some&query=params", "/bar?with=some&query=params", 301]
78
]

tests/Client.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ it('find redirect when rule exist', async () => {
3333
expect(response.location).toBe('/bar')
3434
})
3535

36+
it('find redirect with query params when rule exist', async () => {
37+
const request = createRequest({ path: '/foo?with=some&query=params' })
38+
const response = await client.findRedirect(request)
39+
40+
expect(response).toBeInstanceOf(Response)
41+
expect(response.statusCode).toBe(301)
42+
43+
expect(response.location).toBe('/bar?with=some&query=params')
44+
})
45+
3646
it('send 410 response when rule exist', async () => {
3747
const request = createRequest({ path: '/garply' })
3848
const response = await client.findRedirect(request)

0 commit comments

Comments
 (0)