Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 20, 2020
1 parent a89b9aa commit 0affed6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ var indexOf = callBound('String.prototype.indexOf');
module.exports = function includes(searchString) {
var O = RequireObjectCoercible(this);
var S = ToString(O);
if (IsRegExp(searchString)) throw TypeError();
if (IsRegExp(searchString)) {
throw TypeError('Argument to String.prototype.includes cannot be a RegExp');
}
var searchStr = String(searchString);
var searchLength = searchStr.length;
var position = arguments.length > 1 ? arguments[1] : undefined;
Expand Down

0 comments on commit 0affed6

Please sign in to comment.