Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup
  • Loading branch information
juanarbol committed Sep 9, 2020
commit d4b340e876f586fcd0a6e1e3e1e0f321c7d9be9f
18 changes: 9 additions & 9 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ assert.ifError = function ifError(err) {
}
};

function internalMatch(string, regexp, message, fn, shouldThrows = true) {
function internalMatch(string, regexp, message, fn, shouldThrow = true) {
if (!isRegExp(regexp)) {
throw new ERR_INVALID_ARG_TYPE(
'regexp', 'RegExp', regexp
Expand All @@ -896,11 +896,11 @@ function internalMatch(string, regexp, message, fn, shouldThrows = true) {
if (typeof string !== 'string' ||
RegExpPrototypeTest(regexp, string) !== match) {
if (message instanceof Error) {
if (!shouldThrows) return false;
if (!shouldThrow) return false;
throw message;
}

if (!shouldThrows) return false;
if (!shouldThrow) return false;
const generatedMessage = !message;

// 'The input was expected to not match the regular expression ' +
Expand All @@ -921,14 +921,14 @@ function internalMatch(string, regexp, message, fn, shouldThrows = true) {
err.generatedMessage = generatedMessage;
throw err;
}
if (!shouldThrows) return true;
if (!shouldThrow) return true;
}

assert.match = function match(string, regexp, message, shouldThrows) {
// Undefined shouldThrows and message as boolean
// means message is shouldThrows.
if (!shouldThrows && typeof message === 'boolean') shouldThrows = message;
return internalMatch(string, regexp, message, match, shouldThrows);
assert.match = function match(string, regexp, message, shouldThrow) {
// Undefined shouldThrow and message as boolean
// means message is shouldThrow.
if (!shouldThrow && typeof message === 'boolean') shouldThrow = message;
return internalMatch(string, regexp, message, match, shouldThrow);
};

assert.doesNotMatch = function doesNotMatch(string, regexp, message) {
Expand Down