Changeset 6473
- Timestamp:
- 03/27/07 17:43:30 (1 year ago)
- Files:
-
- spinoffs/prototype/trunk/CHANGELOG (modified) (1 diff)
- spinoffs/prototype/trunk/src/string.js (modified) (1 diff)
- spinoffs/prototype/trunk/test/unit/string.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/prototype/trunk/CHANGELOG
r6393 r6473 1 *SVN* 2 3 * Fix an issue with String.prototype.endsWith. Closes #7822. [altblue] 4 1 5 *1.5.1_rc2* (March 12, 2007) 2 6 spinoffs/prototype/trunk/src/string.js
r6368 r6473 177 177 178 178 startsWith: function(pattern) { 179 return this.indexOf(pattern) == 0;179 return this.indexOf(pattern) === 0; 180 180 }, 181 181 182 182 endsWith: function(pattern) { 183 return this.lastIndexOf(pattern) == (this.length - pattern.length); 183 var d = this.length - pattern.length; 184 return d >= 0 && this.lastIndexOf(pattern) === d; 184 185 }, 185 186 spinoffs/prototype/trunk/test/unit/string.html
r6363 r6473 343 343 assert(!'hello world'.startsWith('bye')); 344 344 assert(!''.startsWith('bye')); 345 assert(!'hell'.startsWith('hello')); 345 346 }}, 346 347 … … 351 352 assert(!''.endsWith('planet')); 352 353 assert('hello world world'.endsWith(' world')); 354 assert(!'z'.endsWith('az')); 353 355 }}, 354 356