Skip to content

Commit

Permalink
fixed framework7io#1248: fix parseUrlQuery compatibility issue and ma…
Browse files Browse the repository at this point in the history
…ke it work more place

modify code more similar with origin
  • Loading branch information
Losan committed Jan 5, 2017
1 parent 18e3f4d commit 6a1a9de
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/js/dom7-utils.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
// DOM Library Utilites
/**
* searchStr: the url need to be parse
* name: the key in parse object , defalut empty
*/
$.parseUrlQuery= function (searchStr, name) {
var qObj = {};
var searchStr = searchStr || location.href;
searchStr = searchStr.indexOf('?')>-1 ? searchStr.replace(/\S*\?/,'') : '';
if (searchStr) {
var params = searchStr.split('&'),
length = params.length, a;

for (var i = 0; i < length; i++) {
a = params[i].replace(/#\S+/g,'').split('=');
qObj[decodeURIComponent(a[0])] = decodeURIComponent(a[1] || '');
$.parseUrlQuery= function (url) {
var url = url || location.href;
var query = {},i, params, param, length;
if (typeof url === 'string' && url.length) {
url = url.indexOf('?')>-1 ? url.replace(/\S*\?/,'') : '';
params = url.split('&'), length = params.length;

for (i = 0; i < length; i++) {
param = params[i].replace(/#\S+/g,'').split('=');
query[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || '');
}
}
return name ? qObj[name] : qObj;

return query;
},
$.isArray = function (arr) {
if (Object.prototype.toString.apply(arr) === '[object Array]') return true;
Expand Down

0 comments on commit 6a1a9de

Please sign in to comment.