Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#525 closed defect (fixed)

dojo.string.endsWith not working

Reported by: guioum Owned by: anonymous
Priority: high Milestone:
Component: Core Version: 0.2
Keywords: Cc:
Blocked By: Blocking:

Description

In "dojo.string.extras"

Test case:

dojo.string.endsWith("mode", "value", false) // returns true, must be false
// "mode".length-"value".length = -1
// "mode".lastIndexOf("value") = -1
// -1 = -1

Is:

    return str.lastIndexOf(end) == str.length - end.length;

Should be:

    var startPos = str.length - end.length;
    if (startPos < 0) {
      return false;
    }
    return (str.lastIndexOf(end, startPos) == startPos);

Thanks. Guioum.

Change History (2)

comment:1 Changed 14 years ago by alex

Milestone: 0.3release
Resolution: fixed
Status: newclosed

fixed in [3353]

comment:2 Changed 12 years ago by (none)

Milestone: 0.3release

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.