This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 3 files changed +11
-51
lines changed
docs/content/error/location
3 files changed +11
-51
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -349,24 +349,17 @@ LocationUrl.prototype = {
349
349
* @return {string } search
350
350
*/
351
351
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 ;
370
363
}
371
364
372
365
this . $$compose ( ) ;
Original file line number Diff line number Diff line change @@ -78,35 +78,6 @@ describe('$location', function() {
78
78
} ) ;
79
79
80
80
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
-
110
81
it ( 'hash() should change hash fragment' , function ( ) {
111
82
url . hash ( 'new-hash' ) ;
112
83
expect ( url . hash ( ) ) . toBe ( 'new-hash' ) ;
You can’t perform that action at this time.
0 commit comments