Skip to content

Commit

Permalink
more lenient string to boolean casting
Browse files Browse the repository at this point in the history
  • Loading branch information
gr0uch committed Jul 30, 2017
1 parent 6c8d7ad commit dd91315
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


### 5.2.11 (2017-07-30)
- Polish: more lenient type casting of string to boolean, to accept more variants of truthy values.
- Polish: fix test setup regarding message not being injected into adapter.


### 5.2.10 (2017-07-29)
- Polish: each instance contains a copy of the message function, to avoid overwriting the global message.

Expand Down
3 changes: 2 additions & 1 deletion lib/common/cast_value.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ var castByType = [
} ],

[ Boolean, function (x) {
if (typeof x === 'string') return x === 'true'
if (typeof x === 'string')
return (/^(?:true|1|yes|t|y)$/i).test(x)
return Boolean(x)
} ],

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fortune",
"description": "Database abstraction layer that implements common features for Node.js and web browsers.",
"version": "5.2.10",
"version": "5.2.11",
"license": "MIT",
"homepage": "http://fortune.js.org",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions test/unit/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ function runTest (adapterFn, options, fn) {
try {
adapter = new AdapterSingleton({
recordTypes,
message,
adapter: [ adapterFn, options ]
})
}
Expand Down

0 comments on commit dd91315

Please sign in to comment.