wappsto-redux
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -13,3 +13,35 @@ import querystring from 'querystring'; | ||
function getUrl(url, query = {}){ | ||
function getQueryObj(query) { | ||
var urlParams = {}; | ||
var match, | ||
pl = /\+/g, | ||
search = /([^&=]+)=?([^&]*)/g, | ||
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }; | ||
while ((match = search.exec(query))) | ||
urlParams[decode(match[1])] = decode(match[2]); | ||
return urlParams; | ||
} | ||
function splitUrlAndOptions(url, options){ | ||
let newOptions = { ...options }; | ||
let split = url.split("?"); | ||
if(split[1]){ | ||
let query = split.slice(1).join("?"); | ||
if(!newOptions.query){ | ||
newOptions.query = getQueryObj(query); | ||
} else { | ||
newOptions.query = { | ||
...newOptions.query, | ||
...getQueryObj(query) | ||
} | ||
} | ||
} | ||
return { | ||
url: split[0], | ||
options: newOptions | ||
} | ||
} | ||
function getUrlWithQuery(url, query = {}){ | ||
let result = config.baseUrl + url; | ||
@@ -31,3 +63,3 @@ if(Object.keys(query).length > 0){ | ||
} | ||
requestOptions.url = getUrl(url, options.query); | ||
requestOptions.url = getUrlWithQuery(url, options.query); | ||
return requestOptions; | ||
@@ -132,2 +164,5 @@ } | ||
method = method.toUpperCase(); | ||
let result = splitUrlAndOptions(url, options); | ||
url = result.url; | ||
options = result.options; | ||
let state = getState(); | ||
@@ -134,0 +169,0 @@ if(state.request[url] && state.request[url].status === 'pending'){ |
{ | ||
"name": "wappsto-redux", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44932
1116