aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/services.js3
-rw-r--r--test/servicesSpec.js8
2 files changed, 9 insertions, 2 deletions
diff --git a/src/services.js b/src/services.js
index 8dad15dc..b215dcdf 100644
--- a/src/services.js
+++ b/src/services.js
@@ -172,8 +172,7 @@ angularServiceInject("$location", function($browser) {
if (isString(path)) {
hash.hashPath = path;
- if (isDefined(search))
- hash.hashSearch = search;
+ hash.hashSearch = search || {};
} else
hash.hashSearch = path;
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index 0876f986..b3f6ec10 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -314,6 +314,14 @@ describe("service", function(){
expect($location.hashPath).toEqual('path');
});
+ it('should reset hashSearch when updating with a single string', function() {
+ $location.updateHash({foo:'bar'}); //set some initial state for hashSearch
+
+ $location.updateHash('path');
+ expect($location.hashPath).toEqual('path');
+ expect($location.hashSearch).toEqual({});
+ });
+
it('should accept single object argument to update search', function() {
$location.updateHash({a: 'b'});
expect($location.hash).toEqual('?a=b');