Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

String#startsWith should throw when a regular expression is passed instead of a string #167

Closed
mathiasbynens opened this issue Dec 17, 2013 · 0 comments · Fixed by #169
Closed

Comments

@mathiasbynens
Copy link
Contributor

This implementation fails the following tests taken from https://github.com/mathiasbynens/String.prototype.startsWith/blob/master/tests/tests.js:

assertThrows(function() { '[a-z]+(bar)?'.startsWith(/[a-z]+/); }, TypeError);
assertThrows(function() { '[a-z]+(bar)?'.startsWith(/(bar)?/); }, TypeError);
assertThrows(function() { '[a-z]+/(bar)?/'.startsWith(/(bar)?/); }, TypeError);

The same goes for endsWith.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant