node-properties
node-properties copied to clipboard
Type coercion should be stable
That is to say that if x
is identified as numerical then the following check should also hold true - else the value should remain of type string:
String( Number( x ) ) === String( x )
For example I have a scenario as follows which leads to an invalid configuration:
foreign_api.verification_token = 000111111 # leading zeros truncated
foreign_api.client_id = 1010101010.10101010101 # too large for float / data loss
I've gotten around this by prefixing an arbitrary token to the value and using the reviver
option to remove it, i.e.
foreign_api.verification_token = --000111111
properties.parse('file', {
// ...
reviver: function(key, value){
if(typeof value === 'string')
return value.replace(/^--\s*/, '');
return this.assert();
},
// ...
);
This seems clunky though and I think most use-cases of node-properties
would benefit from stable type-coercion.
> String (Number("+62")) === String ("+62")
false
I get the same problem. In our .properties
file, there's value that is parsed incorrectly, +62
is parsed as 62