You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because your are doing regex replaces (rebasing) at the same time that you are finding url() references, and your regex replaces a global, if there are two identical url() references, the second one will not be rebased correctly.
For example:
url("../img/blah.png")
url("../img/blah.png")
Rebased to xyz would create:
url("img/blah.png")
url("xyz/img/blah.png")
Perhaps a better way to do this would be to loop through the document and find matches, assign those to an array to de-dup them, and then do a global regexp replace for each one in sequence.
I'm not saying this is a typical situation, but I did run into it. In case you're wondering what I'm doing, I'm using Juice (which uses this package) to do automatic processing of ebook files that were generated by InDesign. The CSS that ID generates is rather repetitive and includes multiple identical url() references, and the rebasing behavior of web-resource-inliner was making Juice explode on me.
The text was updated successfully, but these errors were encountered:
@tooolbox I agree about the proposed solution. There are some related optimizations that should be done to 1) only ever try to retrieve a resource once and 2) technically, someone could want to only replace one reference and not another, but right now if one instance matches than all of the same matches are also replaced. If you have an opportunity to create a PR to fix this that would be awesome.
tooolbox
added a commit
to tooolbox/web-resource-inliner
that referenced
this issue
May 19, 2016
In
css.js
, there is a loop:Because your are doing regex replaces (rebasing) at the same time that you are finding
url()
references, and your regex replaces a global, if there are two identicalurl()
references, the second one will not be rebased correctly.For example:
Rebased to
xyz
would create:Perhaps a better way to do this would be to loop through the document and find matches, assign those to an array to de-dup them, and then do a global regexp replace for each one in sequence.
I'm not saying this is a typical situation, but I did run into it. In case you're wondering what I'm doing, I'm using Juice (which uses this package) to do automatic processing of ebook files that were generated by InDesign. The CSS that ID generates is rather repetitive and includes multiple identical
url()
references, and the rebasing behavior ofweb-resource-inliner
was making Juice explode on me.The text was updated successfully, but these errors were encountered: