Skip to content

Commit

Permalink
Support multiple value while identify image.
Browse files Browse the repository at this point in the history
When metadata has multiple value like keywords parser(./lib/getters.js)
just take the last because parser override the previous value.
Instead of override this commit cast it to array.
  • Loading branch information
emaniacs committed Mar 16, 2016
1 parent d8e8d84 commit 6cd305d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,20 @@ module.exports = function (gm) {
level = indent;

if (val) {
o[key] = val;
// if previous key was exist and we got the same key
// cast it to an array.
if(o.hasOwnProperty(key)){
// cast it to an array and dont forget the previous value
if(!Array.isArray(o[key])){
var tmp = o[key];
o[key] = [tmp];
}

// set value
o[key].push(val);
} else {
o[key] = val;
}

if (key in helper) {
helper[key](o, val);
Expand Down Expand Up @@ -330,3 +343,4 @@ module.exports = function (gm) {
}
};
}

0 comments on commit 6cd305d

Please sign in to comment.