paulmillr/es6-shim

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

mathiasbynens opened this issue · 0 comments

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.