Skip to content

Buggy String#endsWith with position argument #168

@mathiasbynens

Description

@mathiasbynens

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

assertEquals('abc'.endsWith('b', -1), false);
assertEquals('abc'.endsWith('ab', -1), false);

There’s also this issue:

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

…but that’s covered in #167.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions