Skip to content

Commit

Permalink
Fix the ‘getProperty’ method, it's now safe to use special characters…
Browse files Browse the repository at this point in the history
… in property name
  • Loading branch information
František Hába committed Dec 26, 2012
1 parent e6a37c2 commit 54b712d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/engines/json/getProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* @param {object} source
*/
Validation.prototype.getProperty = function(property, source) {
var tree = property.match(/([a-zA-Z0-9\s]+)/g);
return tree.reduce(function(previousValue, currentValue, index) {
return (previousValue && isDefined(previousValue[currentValue])) ? previousValue[currentValue] : undefined;
}, source);
if (source) {
return (source[property]) ? source[property] : undefined;
} else {
return undefined;
}
};

0 comments on commit 54b712d

Please sign in to comment.