From 83145d301ec584808b50ac8c9f0a762803484474 Mon Sep 17 00:00:00 2001 From: Markus Stefanko Date: Thu, 21 Feb 2019 15:22:38 +0700 Subject: [PATCH] Solves #86 `getResponseFromURL` returns now a combined object in which both params from `#` and `?` are combined. This fixes cases such as in #86 and #45 --- src/utils.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/utils.js b/src/utils.js index 3c8d7ae..a140f97 100644 --- a/src/utils.js +++ b/src/utils.js @@ -27,12 +27,16 @@ utils.uuid = function() { * Returns the decoded object, or throws an error if no query string or fragment. */ utils.getResponseFromURL = function (url) { - if (url.indexOf('#') !== -1) { - return utils.parseQueryString(url.substring(url.indexOf('#')+1)) - } else if (url.indexOf('?') !== -1) { - return utils.parseQueryString(url.substring(url.indexOf('?')+1)) + var u = new URL(url); + var hash = {}; + var search = {}; + if (u.hash.indexOf('#') !== -1) { + hash = utils.parseQueryString(u.hash.substring(u.hash.indexOf('#')+1)) } - return {} + if (u.search.indexOf('?') !== -1) { + search = utils.parseQueryString(u.search.substring(u.search.indexOf('?')+1)) + } + return Object.assign({}, hash, search) } utils.parseQueryString = function (qs) {