Skip to content

Commit

Permalink
Guard against falsey non-string values
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFerr committed Nov 16, 2023
1 parent 84aae4f commit ccde3a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Connections/GenericHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ export class GenericHookConnection extends BaseConnection implements IConnection
if (typeof transformationResult.plain !== "string") {
throw Error("Result returned from transformation didn't provide a string value for plain");
}
if (transformationResult.html && typeof transformationResult.html !== "string") {
if (transformationResult.html !== undefined && typeof transformationResult.html !== "string") {
throw Error("Result returned from transformation didn't provide a string value for html");
}
if (transformationResult.msgtype && typeof transformationResult.msgtype !== "string") {
if (transformationResult.msgtype !== undefined && typeof transformationResult.msgtype !== "string") {
throw Error("Result returned from transformation didn't provide a string value for msgtype");
}
content = {
Expand All @@ -405,10 +405,10 @@ export class GenericHookConnection extends BaseConnection implements IConnection
if (typeof transformationResult.webhookResponse.body !== "string") {
throw Error("Result returned from transformation didn't provide a string value for webhookResponse.body");
}
if (transformationResult.webhookResponse.statusCode && typeof transformationResult.webhookResponse.statusCode !== "number" && Number.isInteger(transformationResult.webhookResponse.statusCode)) {
if (transformationResult.webhookResponse.statusCode !== undefined && typeof transformationResult.webhookResponse.statusCode !== "number" && Number.isInteger(transformationResult.webhookResponse.statusCode)) {
throw Error("Result returned from transformation didn't provide a number value for webhookResponse.statusCode");
}
if (transformationResult.webhookResponse.contentType && typeof transformationResult.webhookResponse.contentType !== "string") {
if (transformationResult.webhookResponse.contentType !== undefined && typeof transformationResult.webhookResponse.contentType !== "string") {
throw Error("Result returned from transformation didn't provide a contentType value for msgtype");
}
}
Expand Down

0 comments on commit ccde3a0

Please sign in to comment.