#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 15 years ago by
Milestone: | → 0.3release |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
fixed in [3353]