Reversed toLowerCase removal

pull/3012/head
murgatroid99 9 years ago
parent 5df6ebd0c5
commit 61bb21ab2c
  1. 9
      src/node/src/metadata.js

@ -48,19 +48,12 @@ function Metadata() {
this._internal_repr = {}; this._internal_repr = {};
} }
function downcaseString(str) {
var capitals = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var lowercase = 'abcdefghijklmnopqrstuvwxyz';
var charMap = _.zipObject(capitals, lowercase);
return str.replace(/[A-Z]/g, _.curry(_.get)(charMap));
}
function normalizeKey(key) { function normalizeKey(key) {
if (!(/^[A-Za-z\d-]+$/.test(key))) { if (!(/^[A-Za-z\d-]+$/.test(key))) {
throw new Error('Metadata keys must be nonempty strings containing only ' + throw new Error('Metadata keys must be nonempty strings containing only ' +
'alphanumeric characters and hyphens'); 'alphanumeric characters and hyphens');
} }
return downcaseString(key); return key.toLowerCase();
} }
function validate(key, value) { function validate(key, value) {

Loading…
Cancel
Save