aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/node/src/metadata.js6
-rw-r--r--src/node/test/metadata_test.js8
2 files changed, 8 insertions, 6 deletions
diff --git a/src/node/src/metadata.js b/src/node/src/metadata.js
index 8e0884acea..a7b1ee3810 100644
--- a/src/node/src/metadata.js
+++ b/src/node/src/metadata.js
@@ -102,21 +102,23 @@ Metadata.prototype.add = function(key, value) {
};
/**
- * Remove the given key and any associated values.
+ * Remove the given key and any associated values. Normalizes the key.
* @param {String} key The key to remove
*/
Metadata.prototype.remove = function(key) {
+ key = normalizeKey(key);
if (Object.prototype.hasOwnProperty.call(this._internal_repr, key)) {
delete this._internal_repr[key];
}
};
/**
- * Gets a list of all values associated with the key.
+ * Gets a list of all values associated with the key. Normalizes the key.
* @param {String} key The key to get
* @return {Array.<String|Buffer>} The values associated with that key
*/
Metadata.prototype.get = function(key) {
+ key = normalizeKey(key);
if (Object.prototype.hasOwnProperty.call(this._internal_repr, key)) {
return this._internal_repr[key];
} else {
diff --git a/src/node/test/metadata_test.js b/src/node/test/metadata_test.js
index 227fa9c994..86383f1bad 100644
--- a/src/node/test/metadata_test.js
+++ b/src/node/test/metadata_test.js
@@ -135,10 +135,10 @@ describe('Metadata', function() {
metadata.remove('key');
assert.deepEqual(metadata.get('key'), []);
});
- it('does not normalize keys', function() {
+ it('Normalizes keys', function() {
metadata.add('key', 'value');
metadata.remove('KEY');
- assert.deepEqual(metadata.get('key'), ['value']);
+ assert.deepEqual(metadata.get('key'), []);
});
});
describe('#get', function() {
@@ -150,8 +150,8 @@ describe('Metadata', function() {
it('gets all values associated with a key', function() {
assert.deepEqual(metadata.get('key'), ['value1', 'value2']);
});
- it('does not normalize keys', function() {
- assert.deepEqual(metadata.get('KEY'), []);
+ it('Normalizes keys', function() {
+ assert.deepEqual(metadata.get('KEY'), ['value1', 'value2']);
});
it('returns an empty list for non-existent keys', function() {
assert.deepEqual(metadata.get('non-existent-key'), []);