Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9c53d07

Browse files
committed
revert: fix(location): fix parameter handling on search()
This reverts commit 90532f5. The commit contains references to minErr that are not available in the stable branch.
1 parent 90532f5 commit 9c53d07

File tree

3 files changed

+11
-51
lines changed

3 files changed

+11
-51
lines changed

docs/content/error/location/wpt.ngdoc

-4
This file was deleted.

src/ng/location.js

+11-18
Original file line numberDiff line numberDiff line change
@@ -349,24 +349,17 @@ LocationUrl.prototype = {
349349
* @return {string} search
350350
*/
351351
search: function(search, paramValue) {
352-
switch (arguments.length) {
353-
case 0:
354-
return this.$$search;
355-
case 1:
356-
if (isString(search)) {
357-
this.$$search = parseKeyValue(search);
358-
} else if (isObject(search)) {
359-
this.$$search = search;
360-
} else {
361-
throw $locationMinErr('wpt', 'First parameter of function must be string or an object.');
362-
}
363-
break;
364-
default:
365-
if (paramValue == undefined || paramValue == null) {
366-
delete this.$$search[search];
367-
} else {
368-
this.$$search[search] = paramValue;
369-
}
352+
if (isUndefined(search))
353+
return this.$$search;
354+
355+
if (isDefined(paramValue)) {
356+
if (paramValue === null) {
357+
delete this.$$search[search];
358+
} else {
359+
this.$$search[search] = paramValue;
360+
}
361+
} else {
362+
this.$$search = isString(search) ? parseKeyValue(search) : search;
370363
}
371364

372365
this.$$compose();

test/ng/locationSpec.js

-29
Original file line numberDiff line numberDiff line change
@@ -78,35 +78,6 @@ describe('$location', function() {
7878
});
7979

8080

81-
it('search() should handle multiple value', function() {
82-
url.search('a&b');
83-
expect(url.search()).toEqual({a: true, b: true});
84-
85-
url.search('a', null);
86-
87-
expect(url.search()).toEqual({b: true});
88-
89-
url.search('b', undefined);
90-
expect(url.search()).toEqual({});
91-
});
92-
93-
94-
it('search() should handle single value', function() {
95-
url.search('ignore');
96-
expect(url.search()).toEqual({ignore: true});
97-
});
98-
99-
100-
it('search() should throw error an incorrect argument', function() {
101-
expect(function() {
102-
url.search(null);
103-
}).toThrow('[$location:wpt] First parameter of function must be string or an object.');
104-
expect(function() {
105-
url.search(undefined);
106-
}).toThrow('[$location:wpt] First parameter of function must be string or an object.');
107-
});
108-
109-
11081
it('hash() should change hash fragment', function() {
11182
url.hash('new-hash');
11283
expect(url.hash()).toBe('new-hash');

0 commit comments

Comments
 (0)