prototype 1.5.1_rc2 endsWith is broken when the string length is one
less than pattern length. Fix with the following:
endsWith: function(pattern) {
var index = this.lastIndexOf(pattern)
if(index == -1)
return false
return index == (this.length - pattern.length);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Please post your paches with relevant tests in trac. If you''re unsure how to do that, check http://prototypejs.org/contribute Regards, Tobie On Apr 21, 6:34 pm, Jupiter ITS <JustinBMe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> prototype 1.5.1_rc2 endsWith is broken when the string length is one > less than pattern length. Fix with the following: > > endsWith: function(pattern) { > var index = this.lastIndexOf(pattern) > if(index == -1) > return false > return index == (this.length - pattern.length); > }--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tobie, I issued a patch. As you suggested, I got the latest RC2 but the problem still exists. Also, I''ve seen many other posts in this forum about issues/bugs, is this not the place for them? Thanks for you help, Justin On Apr 21, 6:25 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Please post your paches with relevant tests in trac. > > If you''re unsure how to do that, checkhttp://prototypejs.org/contribute > > Regards, > > Tobie > > On Apr 21, 6:34 pm, Jupiter ITS <JustinBMe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > prototype 1.5.1_rc2 endsWith is broken when the string length is one > > less than pattern length. Fix with the following: > > > endsWith: function(pattern) { > > var index = this.lastIndexOf(pattern) > > if(index == -1) > > return false > > return index == (this.length - pattern.length); > > }- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Justin, Can you please provide a relevant test case where endsWith doesn''t work. Thanks, Tobie On Apr 23, 10:59 am, Jupiter ITS <JustinBMe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Tobie, > I issued a patch. As you suggested, I got the latest RC2 but the > problem still exists. Also, I''ve seen many other posts in this forum > about issues/bugs, is this not the place for them? Thanks for you > help, > > Justin > > On Apr 21, 6:25 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Please post your paches with relevant tests in trac. > > > If you''re unsure how to do that, checkhttp://prototypejs.org/contribute > > > Regards, > > > Tobie > > > On Apr 21, 6:34 pm, Jupiter ITS <JustinBMe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > prototype 1.5.1_rc2 endsWith is broken when the string length is one > > > less than pattern length. Fix with the following: > > > > endsWith: function(pattern) { > > > var index = this.lastIndexOf(pattern) > > > if(index == -1) > > > return false > > > return index == (this.length - pattern.length); > > > }- Hide quoted text - > > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Sure,
The following returns true in IE 6.
''TSubdivision.js''.endsWith(''_controller.html'')
I am using the latest 1.5.1_rc2 prototype downloaded from
http://www.prototypejs.org/download
As I mentioned before, the problem exists whenever the string''s length
is one less than the pattern''s length.
this.lastIndexOf(pattern) == (this.length - pattern.length);
The pattern isn''t matched, so the left side is -1, but the right side
is also negative one.
Thanks for your help, let me know if I''m missing anything.
Justin
p.s. here is a small html file to test from:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scaffold</title>
<script language="javascript" src=''prototype.js''
type="text/
javascript"></script>
<script language="javascript" type="text/javascript">
alert(''TSubdivision.j''.endsWith(''_controller.htm'')
)
</script>
</head>
<body>
</body>
</html>
On Apr 23, 10:36 am, tobie
<tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi Justin,
>
> Can you please provide a relevant test case where endsWith doesn''t
> work.
>
> Thanks,
>
> Tobie
>
> On Apr 23, 10:59 am, Jupiter ITS
<JustinBMe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
> > Tobie,
> > I issued a patch. As you suggested, I got the latest RC2 but the
> > problem still exists. Also, I''ve seen many other posts in
this forum
> > about issues/bugs, is this not the place for them? Thanks for you
> > help,
>
> > Justin
>
> > On Apr 21, 6:25 pm, tobie
<tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > Please post your paches with relevant tests in trac.
>
> > > If you''re unsure how to do that,
checkhttp://prototypejs.org/contribute
>
> > > Regards,
>
> > > Tobie
>
> > > On Apr 21, 6:34 pm, Jupiter ITS
<JustinBMe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > prototype 1.5.1_rc2 endsWith is broken when the string
length is one
> > > > less than pattern length. Fix with the following:
>
> > > > endsWith: function(pattern) {
> > > > var index = this.lastIndexOf(pattern)
> > > > if(index == -1)
> > > > return false
> > > > return index == (this.length - pattern.length);
> > > > }- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi,
you are right, this is not fixed in 1.5.1rc_2, but it is in SVN as so:
String.prototype.endsWith = function(pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
}
Regards,
Tobie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---