I get confused as I switch languages, but testing shows that it will ignore
the extra args; so, yes, remove the p1..string args.

Okay, I buy your argument. I don't know if my confusion was purely me or an
indication that the code should probably have more comments (along the line
of your response about changing all relative urls only which may be
embedded inside other tags in content.) Once you add a comment: :+1:


On Mon, Dec 30, 2013 at 7:06 AM, zubair-arbi <notifications@github.com>wrote:

> In common/static/js/src/utility.js:
>
> > @@ -24,7 +24,17 @@ window.rewriteStaticLinks = function(content, from, to) {
> >      if (from === null || to === null) {
> >          return content;
> >      }
> > -
> > -    var regex = new RegExp(from, 'g');
> > -    return content.replace(regex, to);
> > -};
> > +    // replace only relative urls
> > +    function replacer(match, p1, p2, offset, string){
>
> The approach I wanted to use was to replace all occurrences until unless
> if given string (to be replaced) is inside an absolute url.
> Sample case for match != from (replace '/static/'):
> "http://www.mysite.org/static/bar.jpeg"
>
> @dmitchell <https://github.com/dmitchell> yes you are right about third
> group (p3). As args p1, p2, p3, offset, string will not be used so should I
> replace function replacer(match, p1, p2, offset, string){ with function
> replacer(match){?
> I have added sample urls in my comment below.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/edx/edx-platform/pull/2044/files#r8583783>
> .
>