🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

fastify-qs

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-qs - npm Package Compare versions

Comparing version

to
1.0.4

8

package.json
{
"name": "fastify-qs",
"version": "1.0.3",
"version": "1.0.4",
"description": "Fastify plugin for querystring parsing with qs",

@@ -20,3 +20,7 @@ "keywords": [

"homepage": "https://github.com/webdevium/fastify-qs#readme",
"author": "Vano Devium <webdevium@gmail.com>",
"author": {
"name": "Vano Devium",
"email": "vano.devium@gmail.com",
"url": "https://www.devium.me/"
},
"license": "MIT",

@@ -23,0 +27,0 @@ "private": false,

'use strict'
const packageJson = require('./package.json')
const fp = require('fastify-plugin')
const qs = require('qs')
function plugin (fastify, options, next) {
const plugin = (fastify, options, next) => {
fastify.addHook('onRequest', (request, reply, done) => {

@@ -12,4 +13,4 @@ if (options && options.disabled) {

const url = request.raw.url.replace(/\?{2,}/, '?')
const queryExists = url.indexOf('?')
const query = queryExists > -1 ? url.slice(queryExists + 1) : ''
const querySymbolIndex = url.indexOf('?')
const query = querySymbolIndex !== -1 ? url.slice(querySymbolIndex + 1) : ''
request.query = qs.parse(query, options)

@@ -23,3 +24,3 @@ done()

fastify: '>= 1.0.0',
name: 'fastify-qs'
name: packageJson.name
})
# fastify-qs
[![Build Status](https://travis-ci.org/webdevium/fastify-qs.svg?branch=master)](https://travis-ci.org/webdevium/fastify-qs)
[![GitHub issues](https://img.shields.io/github/issues/webdevium/fastify-qs)](https://github.com/webdevium/fastify-qs/issues)
[![GitHub license](https://img.shields.io/github/license/webdevium/fastify-qs)](https://github.com/webdevium/fastify-qs/blob/master/LICENSE.MD)
[![npm](https://img.shields.io/npm/v/fastify-qs)](https://www.npmjs.com/package/fastify-qs)
A plugin for [Fastify](https://fastify.io/) that adds support for parsing URL query parameters with [qs](https://www.npmjs.com/package/qs).
Plugin accept any options from [qs.parse](https://www.npmjs.com/package/qs#parsing-objects) method
Plugin accepts any options from [qs.parse](https://www.npmjs.com/package/qs#parsing-objects) method
## Install
```
npm i fastify-qs
```
## Example

@@ -10,0 +18,0 @@

@@ -18,3 +18,3 @@ 'use strict'

{ options: null, querystring: null, expected: {} }
].forEach(function (testData) {
].forEach(testData => {
test('parses querystring with qs: ' + testData.querystring, (t) => {

@@ -40,7 +40,8 @@ t.plan(1)

const port = fastify.server.address().port
const queryString = testData.querystring ? '?' + testData.querystring : ''
get.concat({
url: `http://127.0.0.1:${port}/${testData.querystring ? '?' + testData.querystring : ''}`,
url: `http://127.0.0.1:${port}/${queryString}`,
json: true
}, function (err, res, data) {
}, (err, res, data) => {
if (err) {

@@ -47,0 +48,0 @@ t.error(err)

Sorry, the diff of this file is not supported yet