Thanks, I've included the minors, I didn't change to the regex because
of the escaping. If someone else needs this sort of method I'd be happy
to improve those for reuse but we made it pretty far w/o.
https://codereview.appspot.com/7327045/diff/16001/app/assets/javascripts/routing.js#newcode5
app/assets/javascripts/routing.js:5: function _trim(s, char, leading,
trailing) {
On 2013/02/18 20:00:06, benji wrote:
> On 2013/02/18 17:12:47, jeff.pihach wrote:
> > This feels like a generic utility method which could be split out
into a
> > separate utility method module
> +1 I'm surprised trimming strings isn't already available in JS or
YUI.
> > and hung off Y.Lang so that it's available application wide.
> -1 to injecting ourselves into a third-party library
> > As a generic utility method it would probably be best solved using a
regex. Ln
> > 5-18 could be replaced with:
> >
> > ** WARNING - incoming untested code **
> >
> > Y.Lang.trimString = function(str, start, end) {
> >
> > var trimRegex = new RegExp("^[" + start + "]+|[" + end +
"]+$","g");
> > return str.replace(trimRegex, "");
> >
> > }
> Building regexes programmatically requires escaping the inputs.
> For example, what if I want to trim any leading "bar" off a string and
I pass in
> "bar" as the start parameter and "rabid" as the str. Instead of
getting "rabid"
> back (because the prefix wasn't there to get removed) I instead get
back "id"
> because my start string was interpreted as a set of characters not a
literal
> string.
Thanks, I've included the minors, I didn't change to the regex because
of the escaping. If someone else needs this sort of method I'd be happy
to improve those for reuse but we made it pretty far w/o.
https:/ /codereview. appspot. com/7327045/ diff/16001/ app/assets/ javascripts/ routing. js javascripts/ routing. js (right):
File app/assets/
https:/ /codereview. appspot. com/7327045/ diff/16001/ app/assets/ javascripts/ routing. js#newcode5 javascripts/ routing. js:5: function _trim(s, char, leading,
app/assets/
trailing) {
On 2013/02/18 20:00:06, benji wrote:
> On 2013/02/18 17:12:47, jeff.pihach wrote:
> > This feels like a generic utility method which could be split out
into a
> > separate utility method module
> +1 I'm surprised trimming strings isn't already available in JS or
YUI.
> > and hung off Y.Lang so that it's available application wide.
> -1 to injecting ourselves into a third-party library
> > As a generic utility method it would probably be best solved using a trimRegex, "");
regex. Ln
> > 5-18 could be replaced with:
> >
> > ** WARNING - incoming untested code **
> >
> > Y.Lang.trimString = function(str, start, end) {
> >
> > var trimRegex = new RegExp("^[" + start + "]+|[" + end +
"]+$","g");
> > return str.replace(
> >
> > }
> Building regexes programmatically requires escaping the inputs.
> For example, what if I want to trim any leading "bar" off a string and
I pass in
> "bar" as the start parameter and "rabid" as the str. Instead of
getting "rabid"
> back (because the prefix wasn't there to get removed) I instead get
back "id"
> because my start string was interpreted as a set of characters not a
literal
> string.
Done.
https:/ /codereview. appspot. com/7327045/ diff/16001/ app/assets/ javascripts/ routing. js#newcode96 javascripts/ routing. js:96: console.log('URL has more than one reference :-) also see above comment about Y.log()
app/assets/
refernce to same namespace');
On 2013/02/18 17:12:47, jeff.pihach wrote:
> s/refernce/
Done.
https:/ /codereview. appspot. com/7327045/ diff/16001/ app/assets/ javascripts/ routing. js#newcode113 javascripts/ routing. js:113: var u = '/';
app/assets/
On 2013/02/18 17:12:47, jeff.pihach wrote:
> u is url? Please don't manually minify - use meaningful variable names
</pet
> peeve> :-)
Done.
https:/ /codereview. appspot. com/7327045/