Comparing version 0.0.7 to 0.0.8
@@ -576,3 +576,3 @@ (function() { | ||
return function(namespace, params, options) { | ||
var search; | ||
var isTargetEqualSource, key, ref, ref1, search, uri, value; | ||
if (options == null) { | ||
@@ -590,12 +590,32 @@ options = {}; | ||
*/ | ||
_this.isReloadAtThisRender = options.reload; | ||
if (namespace[0] === '/') { | ||
$location.url(namespace); | ||
isTargetEqualSource = $location.url() === namespace; | ||
} else { | ||
search = {}; | ||
$location.path(_this.href(namespace, params, search)); | ||
$location.search(search); | ||
ref = _this.href(namespace, params), uri = ref.uri, search = ref.search; | ||
isTargetEqualSource = $location.path() === uri && Object.keys($location.search()).length === Object.keys(search).length; | ||
if (isTargetEqualSource) { | ||
ref1 = $location.search(); | ||
for (key in ref1) { | ||
value = ref1[key]; | ||
if (!(search[key] !== value)) { | ||
continue; | ||
} | ||
isTargetEqualSource = false; | ||
break; | ||
} | ||
} | ||
} | ||
if (options.replace) { | ||
return $location.replace(); | ||
if (isTargetEqualSource) { | ||
return _this.reload(true); | ||
} else { | ||
_this.isReloadAtThisRender = options.reload; | ||
if (namespace[0] === '/') { | ||
$location.url(namespace); | ||
} else { | ||
$location.path(uri); | ||
$location.search(search); | ||
} | ||
if (options.replace) { | ||
return $location.replace(); | ||
} | ||
} | ||
@@ -616,4 +636,4 @@ }; | ||
this.href = (function(_this) { | ||
return function(namespace, params, search) { | ||
var href, paramKey, paramValue, queryString, rule, usedKey; | ||
return function(namespace, params) { | ||
var href, paramKey, paramValue, queryString, rule, search, usedKey; | ||
if (params == null) { | ||
@@ -627,4 +647,6 @@ params = {}; | ||
@param params {object} The params of the rule. | ||
@param search {object|null} If it is an object, query string will appended at here, else append query string at href. | ||
@returns {string} The url. | ||
@returns {object} | ||
uri: {string} | ||
uriWithSearch: {string} | ||
search: {object} | ||
*/ | ||
@@ -645,22 +667,21 @@ rule = _this.rules[namespace]; | ||
} | ||
if (search != null) { | ||
for (paramKey in params) { | ||
paramValue = params[paramKey]; | ||
if (indexOf.call(usedKey, paramKey) < 0) { | ||
search[paramKey] = paramValue; | ||
} | ||
search = {}; | ||
for (paramKey in params) { | ||
paramValue = params[paramKey]; | ||
if (indexOf.call(usedKey, paramKey) < 0) { | ||
search[paramKey] = paramValue; | ||
} | ||
} else { | ||
queryString = []; | ||
for (paramKey in params) { | ||
paramValue = params[paramKey]; | ||
if (indexOf.call(usedKey, paramKey) < 0) { | ||
queryString.push((encodeURIComponent(paramKey)) + "=" + (encodeURIComponent(paramValue))); | ||
} | ||
} | ||
queryString = []; | ||
for (paramKey in params) { | ||
paramValue = params[paramKey]; | ||
if (indexOf.call(usedKey, paramKey) < 0) { | ||
queryString.push((encodeURIComponent(paramKey)) + "=" + (encodeURIComponent(paramValue))); | ||
} | ||
if (queryString.length) { | ||
href += "?" + (queryString.join('&')); | ||
} | ||
} | ||
return href; | ||
return { | ||
uri: href, | ||
uriWithSearch: href + "?" + (queryString.join('&')), | ||
search: search | ||
}; | ||
}; | ||
@@ -667,0 +688,0 @@ })(this); |
{ | ||
"name": "poi-router", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "An AngularJS router.", | ||
@@ -5,0 +5,0 @@ "main": "dist/poi-router.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
76025
808