From 61f4395534ddac50414c96306bc98eda0a5cb2e4 Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Sun, 12 Feb 2017 16:22:22 -0500 Subject: [PATCH] query decoding bug fix (thanks @fongandrew) closes #12 --- .versions | 72 ++++++++++++++++++++++++++++++++++++------------------ History.md | 4 +++ lib/url.js | 10 ++++---- package.js | 4 +-- 4 files changed, 59 insertions(+), 31 deletions(-) diff --git a/.versions b/.versions index 0aae3da..e93597f 100644 --- a/.versions +++ b/.versions @@ -1,24 +1,48 @@ -base64@1.0.3 -binary-heap@1.0.3 -callback-hook@1.0.3 -check@1.0.5 -ddp@1.1.0 -ejson@1.0.6 -geojson-utils@1.0.3 -id-map@1.0.3 -iron:core@1.0.8 -iron:url@1.0.9 -jquery@1.11.3_2 -json@1.0.3 -local-test:iron:url@1.0.9 -logging@1.0.7 -meteor@1.1.6 -minimongo@1.0.8 -mongo@1.1.0 -ordered-dict@1.0.3 -random@1.0.3 -retry@1.0.3 -test-helpers@1.0.4 -tinytest@1.0.5 -tracker@1.0.7 -underscore@1.0.3 +babel-compiler@5.8.24_1 +babel-runtime@0.1.4 +base64@1.0.4 +binary-heap@1.0.4 +blaze@2.1.3 +blaze-tools@1.0.4 +boilerplate-generator@1.0.4 +callback-hook@1.0.4 +check@1.0.6 +ddp@1.2.2 +ddp-client@1.2.1 +ddp-common@1.2.1 +ddp-server@1.2.1 +deps@1.0.9 +diff-sequence@1.0.1 +ecmascript@0.1.5 +ecmascript-collections@0.1.6 +ejson@1.0.7 +geojson-utils@1.0.4 +html-tools@1.0.5 +htmljs@1.0.5 +id-map@1.0.4 +iron:core@1.0.11 +iron:url@1.0.11 +jquery@1.11.4 +local-test:iron:url@1.0.11 +logging@1.0.8 +meteor@1.1.9 +minimongo@1.0.10 +mongo@1.1.2 +mongo-id@1.0.1 +npm-mongo@1.4.39_1 +observe-sequence@1.0.7 +ordered-dict@1.0.4 +promise@0.5.0 +random@1.0.4 +reactive-var@1.0.6 +retry@1.0.4 +routepolicy@1.0.6 +spacebars@1.0.7 +spacebars-compiler@1.0.7 +test-helpers@1.0.5 +tinytest@1.0.6 +tracker@1.0.9 +ui@1.0.8 +underscore@1.0.4 +webapp@1.2.2 +webapp-hashing@1.0.5 diff --git a/History.md b/History.md index 9b60cf9..096cefb 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +v1.1.1 / 2017-02-12 +================== + * Query param bugfix (urlencoded '%' character) + v1.0.11 / 2015-10-09 ================== * Support Meteor 1.2 diff --git a/lib/url.js b/lib/url.js index b8538e6..2ae0d6f 100644 --- a/lib/url.js +++ b/lib/url.js @@ -101,10 +101,12 @@ Url.fromQueryString = function (query) { _.each(keyValuePairs, function (pair) { var parts = pair.split('='); - var key = parts[0]; + var key = safeDecodeURIComponent(parts[0]); var value = safeDecodeURIComponent(parts[1]); - if (key.slice(-2) === '[]') { + if (typeof key !== 'undefined' && + typeof value !== 'undefined' && + key.slice(-2) === '[]') { key = key.slice(0, -2); result[key] = result[key] || []; result[key].push(value); @@ -283,9 +285,7 @@ Url.prototype.params = function (path) { params.push(value); } - path = safeDecodeURI(path); - - if (typeof path !== 'undefined') { + if (typeof safeDecodeURI(path) !== 'undefined') { queryString = path.split('?')[1]; if (queryString) queryString = queryString.split('#')[0]; diff --git a/package.js b/package.js index 617f69b..de22a17 100644 --- a/package.js +++ b/package.js @@ -1,13 +1,13 @@ Package.describe({ name: 'iron:url', summary: 'Url utilities and support for compiling a url into a regular expression.', - version: '1.0.11', + version: '1.1.0', git: 'https://github.com/iron-meteor/iron-url' }); Package.on_use(function (api) { api.versionsFrom('METEOR@0.9.2'); - + api.use('underscore'); api.use('iron:core@1.0.11');