|
|
@ -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) { |
|
|
|