mirror of https://github.com/grpc/grpc-node.git
Replaced toLowerCase with local-insensitive downcasing function
This commit is contained in:
parent
d731161616
commit
79fa8dbad1
|
@ -48,12 +48,19 @@ 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 key.toLowerCase();
|
return downcaseString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate(key, value) {
|
function validate(key, value) {
|
||||||
|
|
Loading…
Reference in New Issue