|
|
@ -49,14 +49,14 @@ function Metadata() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function normalizeKey(key) { |
|
|
|
function normalizeKey(key) { |
|
|
|
|
|
|
|
if (!(/^[A-Za-z\d-]+$/.test(key))) { |
|
|
|
|
|
|
|
throw new Error('Metadata keys must be nonempty strings containing only ' + |
|
|
|
|
|
|
|
'alphanumeric characters and hyphens'); |
|
|
|
|
|
|
|
} |
|
|
|
return key.toLowerCase(); |
|
|
|
return key.toLowerCase(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function validate(key, value) { |
|
|
|
function validate(key, value) { |
|
|
|
if (!(/^[a-z\d-]+$/.test(key))) { |
|
|
|
|
|
|
|
throw new Error('Metadata keys must be nonempty strings containing only ' + |
|
|
|
|
|
|
|
'alphanumeric characters and hyphens'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (_.endsWith(key, '-bin')) { |
|
|
|
if (_.endsWith(key, '-bin')) { |
|
|
|
if (!(value instanceof Buffer)) { |
|
|
|
if (!(value instanceof Buffer)) { |
|
|
|
throw new Error('keys that end with \'-bin\' must have Buffer values'); |
|
|
|
throw new Error('keys that end with \'-bin\' must have Buffer values'); |
|
|
|