Skip to content

Commit

Permalink
Fixed empty string not being returned.
Browse files Browse the repository at this point in the history
This closes #59.
  • Loading branch information
rmariuzzo committed Nov 23, 2017
1 parent e3c8143 commit 5220d6c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lang.js
Expand Up @@ -284,7 +284,7 @@
var subKey = '';
while (entries.length && message !== undefined) {
var subKey = !subKey ? entries.shift() : subKey.concat('.', entries.shift());
if (message[subKey]) {
if (message[subKey] !== undefined) {
message = message[subKey]
subKey = '';
}
Expand Down
3 changes: 2 additions & 1 deletion test/fixture/messages.json
Expand Up @@ -114,7 +114,8 @@
},
"dotInKey": {
"dot.in.key": "Dot In Key Nested Simple"
}
},
"empty": ""
},
"en.pagination": {
"previous": "« Previous",
Expand Down
4 changes: 4 additions & 0 deletions test/spec/lang_get_spec.js
Expand Up @@ -73,4 +73,8 @@ describe('The lang.get() method', function () {
expect(lang.get('messages.dotInKey.dot.in.key')).toBe('Dot In Key Nested Simple');
expect(lang.get('messages.dot.in.key2.nested.dot.in.key2.nested')).toBe('Dot In Key Nested Tricky');
});

it('should return an empty string', function() {
expect(lang.get('messages.empty')).toBe('');
})
});

0 comments on commit 5220d6c

Please sign in to comment.