-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from nzzdev/release-10.0.1
Release 10.0.1
- Loading branch information
Showing
19 changed files
with
90 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const Bourne = require("@hapi/bourne"); | ||
const Joi = require("@hapi/joi"); | ||
|
||
// As of Joi v16, strings are no longer automatically converted to objects/arrays, | ||
// even if the convert option of any.validate() is "true" (which is the default). | ||
// => A string such as '{"foo": "bar"}' is not valid for Joi.object(). | ||
// And '["foo", "bar"]' is not valid for Joi.array(). | ||
// This is a problem when passing objects/arrays in HTTP query strings, where they | ||
// can only be represented as strings. This custom extension allows converting | ||
// objects/arrays to strings as it was done in Joi v15 and before. | ||
// Adapted from https://github.com/hapijs/joi/issues/2037 | ||
// (section "Array and object string coercion") | ||
module.exports = Joi.extend( | ||
{ | ||
type: "object", | ||
base: Joi.object(), | ||
coerce: { | ||
from: "string", | ||
method(value) { | ||
if (value[0] !== "{" && !/^\s*\{/.test(value)) { | ||
return; | ||
} | ||
|
||
try { | ||
return { value: Bourne.parse(value) }; | ||
} catch (ignoreErr) {} | ||
} | ||
} | ||
}, | ||
{ | ||
type: "array", | ||
base: Joi.array(), | ||
coerce: { | ||
from: "string", | ||
method(value) { | ||
if ( | ||
typeof value !== "string" || | ||
(value[0] !== "[" && !/^\s*\[/.test(value)) | ||
) { | ||
return; | ||
} | ||
|
||
try { | ||
return { value: Bourne.parse(value) }; | ||
} catch (ignoreErr) {} | ||
} | ||
} | ||
} | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters