From cafcde01ec3513591fb5c093ee22f03891c6ff3b Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 11 Aug 2013 12:18:58 -0400 Subject: [PATCH] bug fixes: don't allow dotSet/Get on undefined paths, remove @hydrate from derbyUserToAPI() --- script/helpers.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script/helpers.coffee b/script/helpers.coffee index a491117493..14a749f48f 100644 --- a/script/helpers.coffee +++ b/script/helpers.coffee @@ -112,6 +112,7 @@ module.exports = Angular sets object properties directly - in which case, this function will be used. ### dotSet: (path, val, obj) -> + return if ~path.indexOf('undefined') arr = path.split('.') _.reduce arr, (curr, next, index) -> if (arr.length - 1) == index @@ -119,7 +120,9 @@ module.exports = curr[next] , obj - dotGet: (path, obj) -> _.reduce path.split('.'), ((curr, next) -> curr[next]), obj + dotGet: (path, obj) -> + return undefined if ~path.indexOf('undefined') + _.reduce path.split('.'), ((curr, next) -> curr[next]), obj daysBetween: daysBetween @@ -361,7 +364,7 @@ module.exports = local ops, because the var-by-reference lets us edit the original tasks ### derbyUserToAPI: (userScope, keepTasks=true) -> - uObj = @hydrate userScope.get() + uObj = userScope.get() _.each ['habit','daily','todo','reward'], (type) -> # we use _.transform instead of a simple _.where in order to maintain sort-order uObj["#{type}s"] = _.transform uObj["#{type}Ids"], (result, tid) -> result.push(uObj.tasks[tid])