Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners committed Feb 12, 2018
1 parent c4ceabf commit 65b158b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -27,14 +27,14 @@
},
"homepage": "https://github.com/fastify/fastify-url-data#readme",
"devDependencies": {
"fastify": "^0.30.3",
"fastify": "^1.0.0-rc.1",
"pre-commit": "^1.2.2",
"snazzy": "^7.0.0",
"standard": "^10.0.3",
"tap": "^10.7.2"
"tap": "^11.1.0"
},
"dependencies": {
"fastify-plugin": "^0.1.1",
"fastify-plugin": "^0.2.2",
"uri-js": "^3.0.2"
}
}
5 changes: 4 additions & 1 deletion plugin.js
Expand Up @@ -12,4 +12,7 @@ function plugin (fastify, options, next) {
next()
}

module.exports = fp(plugin, '>=0.15.0')
module.exports = fp(plugin, {
fastify: '>=1.0.0-rc.1',
name: 'fastify-url-data'
})
58 changes: 31 additions & 27 deletions test/tests.test.js
@@ -1,39 +1,43 @@
'use strict'

const http = require('http')
const tap = require('tap')
const test = tap.test
const fastify = require('fastify')()
const test = require('tap').test
const Fastify = require('fastify')
const plugin = require('../')

fastify.register(plugin, (err) => {
if (err) tap.error(err)
})

fastify.listen(0, (err) => {
if (err) tap.error(err)
fastify.server.unref()
test('parses a full URI', (t) => {
t.plan(8)
let port
const fastify = Fastify()

const port = fastify.server.address().port
fastify
.register(plugin)
.after((err) => {
if (err) t.error(err)
})

test('parses a full URI', (t) => {
t.plan(8)
fastify.get('/one', (req, reply) => {
const uriData = req.urlData()
t.is(uriData.host, '127.0.0.1')
t.is(uriData.port, port)
t.is(uriData.path, '/one')
t.is(uriData.query, 'a=b&c=d')
t.is(req.urlData('host'), '127.0.0.1')
t.is(req.urlData('port'), port)
t.is(req.urlData('path'), '/one')
t.is(req.urlData('query'), 'a=b&c=d')
reply.send()
})

fastify.get('/one', (req, reply) => {
const uriData = req.urlData()
t.is(uriData.host, '127.0.0.1')
t.is(uriData.port, port)
t.is(uriData.path, '/one')
t.is(uriData.query, 'a=b&c=d')
t.is(req.urlData('host'), '127.0.0.1')
t.is(req.urlData('port'), port)
t.is(req.urlData('path'), '/one')
t.is(req.urlData('query'), 'a=b&c=d')
reply.send()
})
fastify.listen(0, (err) => {
fastify.server.unref()
if (err) t.threw(err)

port = fastify.server.address().port
http
.get(`http://127.0.0.1:${port}/one?a=b&c=d#foo`, (res) => {})
.on('error', t.threw)
.get(`http://127.0.0.1:${port}/one?a=b&c=d#foo`, (res) => {})
.on('error', t.threw)
})

t.tearDown(() => fastify.close())
})

0 comments on commit 65b158b

Please sign in to comment.