-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix: make port optional when parsing URL #154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind to add a test to cover this use case?
Currently trying to figure out a way to reproduce this in a test. At least what doesn't work in my case works when trying in this test env. I tried this: test('should parse path without a port specified', async (t) => {
t.plan(2)
const fastify = Fastify()
fastify
.register(plugin)
fastify.get('/', (req, reply) => {
const path = req.urlData('path')
reply.send('That worked, path is ' + path)
})
const res = await fastify.inject({ url: '/' })
t.equal(res.statusCode, 200)
t.equal(res.body, 'That worked, path is /')
}) |
URL parsing is broken when port is not specified, as the URL is basically invalid in this case. Fixes fastify#153 Signed-off-by: Julian <julian@svg4all.de>
Done :D this basically also adds a workaround for my usecase: specify a port in the host header of the inject call. Took me this test to find out ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
URL parsing is broken when port is not specified, as the URL is basically invalid in this case.
Fixes #153
Checklist
npm run test
andnpm run benchmark
and the Code of conduct