From d8e0b0135809b3bb4f501326d357180192b29957 Mon Sep 17 00:00:00 2001 From: Diana Shkolnikov Date: Tue, 6 Sep 2016 09:10:32 -0400 Subject: [PATCH] Cleanup a few small things --- helper/diffPlaces.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/helper/diffPlaces.js b/helper/diffPlaces.js index c13e5827..712c7959 100644 --- a/helper/diffPlaces.js +++ b/helper/diffPlaces.js @@ -20,7 +20,7 @@ function assertLayerMatch(item1, item2) { } /** - * Compare the parent.* properties if they exist. + * Compare the parent.*_id properties if they exist. * Returns false if the objects are the same, and throws * an exception with the message 'different' if not. * @@ -64,7 +64,7 @@ function assertParentHierarchyMatch(item1, item2) { function assertNameMatch(item1, item2) { if (item1.hasOwnProperty('name') && item2.hasOwnProperty('name')) { for (var lang in item1.name) { - if(item2.name[lang] || lang === 'default') { + if(item2.name.hasOwnProperty(lang) || lang === 'default') { // do not consider absence of an additional name as a difference propMatch(item1.name, item2.name, lang); } @@ -163,9 +163,14 @@ function propMatch(item1, item2, prop) { * @returns {string} */ function normalizeString(str) { - if (!str) { + if (!_.isString(str)) { + return str; + } + + if (_.isEmpty(str)) { return ''; } + return str.toLowerCase().split(/[ ,-]+/).join(' '); }