My use-case of extending this is to add URL rewriting to JS source map
references, e.g. {{{//# sourceMappingURL=foo.js.map }}} which can appear
at the end of JS files. I need to be able to rewrite these URLs in the
same way that Django's staticfiles can rewrite URLs in CSS, for e.g.
adding hashes to filenames.
Once I tried extending {{{patterns}}} with this:
{{{
patterns = HashedFilesMixin.patterns + (
("*.js", (
(r"""(//# sourceMappingURL=(\s*))""", """//#
sourceMappingURL=%s"""),
)),
)
}}}
The surprising and broken behavior was that Django tried to rewrite "URLs"
for this JS (from Backbone.js): {{{this.loadUrl(window.location.hash)}}},
which matched the CSS pattern for rewriting {{{url(foo)}}} because the
regex patterns are case-insensitive.
This also applies to the previous {{{CachedFilesMixin}}} from before 1.7.
Please let me know if a fix for this would be accepted, and I'll put
together a test case and patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/22972>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:1>
* owner: nobody => aehlke
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:2>
Comment (by aehlke):
I'm preparing a test case and patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:3>
Comment (by aehlke):
I've submitted a pull request with test coverage (a test which fails
before applying the patch) and patch for the fix. Please let me know if
anything needs changing.
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:4>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:5>
* type: Uncategorized => Bug
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:6>
* version: 1.7-rc-1 => master
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:7>
* status: assigned => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:8>
Comment (by aehlke):
This patterns property is also documented in the Django docs, which I
think adds priority to getting this fixed as it makes it sound like
something you can extend (where in current versions you cannot actually
extend without subtly broken behavior.)
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:9>
* status: closed => new
* resolution: fixed =>
Comment:
A ticket shouldn't be closed until the fix is committed to Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:10>
Comment (by aehlke):
timo: Ah ok, sorry about that. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:11>
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
I left comments for improvement on the PR. Please uncheck "Patch needs
improvement" when you update it, thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:12>
Comment (by jaylett):
Is this the same as #19670?
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:13>
* status: new => closed
* resolution: => duplicate
Comment:
Replying to [comment:13 jaylett]:
> Is this the same as #19670?
I think so.
--
Ticket URL: <https://code.djangoproject.com/ticket/22972#comment:14>