diff options
| author | Igor Minar | 2010-09-27 16:00:05 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-09-29 09:52:03 -0700 |
| commit | eb8d46d380a2005dbec3973d40e1dbc27991fdb7 (patch) | |
| tree | 59a3e8d7bba0c4704b759efb38d1c72e5a85dc75 /src/Angular.js | |
| parent | 984acdc6270df1dee5796ed44efebfb9ff6706c7 (diff) | |
| download | angular.js-eb8d46d380a2005dbec3973d40e1dbc27991fdb7.tar.bz2 | |
Differentiate between flags and empty keys in $location.hashSearch
* #foo?key=var&flag&emptyKey= should parse into
{key:'val', flag: true, emptyKey: ''}
* added docs and spec for parseKeyValue function
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Angular.js b/src/Angular.js index 2bd21de4..3e53c755 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -370,13 +370,17 @@ function compile(element, existingScope) { } ///////////////////////////////////////////////// -function parseKeyValue(keyValue) { +/** + * Parses an escaped url query string into key-value pairs. + * @return Object.<(string|boolean)> + */ +function parseKeyValue(/**string*/keyValue) { var obj = {}, key_value, key; foreach((keyValue || "").split('&'), function(keyValue){ if (keyValue) { key_value = keyValue.split('='); key = unescape(key_value[0]); - obj[key] = key_value[1] ? unescape(key_value[1]) : true; + obj[key] = isDefined(key_value[1]) ? unescape(key_value[1]) : true; } }); return obj; |
