Skip to content

Commit

Permalink
Prevent runtime error in a case of passing null to camelCaseToUndersc…
Browse files Browse the repository at this point in the history
…oreRequest. Related to RealFaviconGenerator#27
  • Loading branch information
FlyingDR committed Apr 12, 2021
1 parent 11a7cf9 commit b87fc74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ module.exports.init = function() {
if (request === undefined) {
return undefined;
}
else if (request === null) {
return null;
}
if (request.constructor === Array) {
for (var i = 0; i < request.length; i++) {
request[i] = exports.camelCaseToUnderscoreRequest(request[i]);
Expand Down
2 changes: 2 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ describe('RFG Api', function() {

assert.equal(rfg.camelCaseToUnderscoreRequest(undefined), undefined);

assert.equal(rfg.camelCaseToUnderscoreRequest(null), null);

assert.deepEqual(rfg.camelCaseToUnderscoreRequest({
firstEntry: 'firstValue',
secondEntry: [
Expand Down

0 comments on commit b87fc74

Please sign in to comment.