"use strict";

var url = require("url");

function prepareRequest(req) {
    //extract req.query
    req.parsedUrl = url.parse(req.url, true);
    req.query = req.parsedUrl.query || {};

    //overwrite req.body with req.query on GET requests
    //TODO really overwrite here?
    //it makes a difference between http/ws!
    if (req.method === "GET" && Object.keys(req.body).length === 0 && req.query !== {}) {
        req.body = req.query;
    }
}

module.exports = prepareRequest;
"use strict";

var url = require("url");

function prepareRequest(req) {
    //extract req.query
    req.parsedUrl = url.parse(req.url, true);
    req.query = req.parsedUrl.query || {};

    //overwrite req.body with req.query on GET requests
    //TODO really overwrite here?
    //it makes a difference between http/ws!
    if (req.method === "GET" && req.body && Object.keys(req.body).length === 0 && req.query !== {}) {
        req.body = req.query;
    }
}

module.exports = prepareRequest;
Add check for body to fix bug when called without bodyParser
Add check for body to fix bug when called without bodyParser
