prototype: String.prototype.endsWith should not fail on multiple occurrences. Closes #7416.

This commit is contained in:
Sam Stephenson 2007-02-05 04:56:46 +00:00
parent 225bf0e6ec
commit 74596ac289
3 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* String.prototype.endsWith should not fail on multiple occurrences. Closes #7416. [Christophe Porteneuve]
* Add Form.Methods.request as a convenience method for serializing and submitting a form via Ajax.Request to the URL in the form's action attribute. [sam]
Options passed to request() are intelligently merged with the underlying Ajax.Request options:

View File

@ -151,7 +151,7 @@ Object.extend(String.prototype, {
},
endsWith: function(pattern){
return this.indexOf(pattern) == (this.length - pattern.length);
return this.lastIndexOf(pattern) == (this.length - pattern.length);
}
});

View File

@ -343,6 +343,7 @@
assert('hello world'.endsWith(' world'));
assert(!'hello world'.endsWith('planet'));
assert(!''.endsWith('planet'));
assert('hello world world'.endsWith(' world'));
}},
testSucc: function() {with(this) {