From 2c4728b1538c1df129b8b772c06353a7eede5236 Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Thu, 9 Feb 2017 15:54:03 +0100 Subject: [PATCH] Add deprecation warning to parseQuery This deprecation warning is intended to alarm loader authors that passing an object to parseQuery and then modifying it might lead to unintended behavior. #56 --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ed4e456..96ebc08 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ var JSON5 = require("json5"); var path = require("path"); +var util = require("util"); +var os = require("os"); var assign = require("object-assign"); var emojiRegex = /[\uD800-\uDFFF]./; var emojiList = require("emojis-list").filter(function(emoji) { @@ -65,7 +67,11 @@ exports.parseQuery = function parseQuery(query) { }; if(!query) return {}; if(typeof query !== "string") - return query; + return (util.deprecate(function () {}, + "loaderUtils.parseQuery() just received a value type of " + typeof query + + " which can be problematic, see https://github.com/webpack/loader-utils/issues/56" + os.EOL + + "parseQuery() will be replaced with getOptions() in the next major version of loader-utils."))(), + query; if(query.substr(0, 1) !== "?") throw new Error("a valid query string passed to parseQuery should begin with '?'"); query = query.substr(1);