Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

File hash incorrectly inserted into partial filename match #40

Open
jayhung opened this issue Jun 15, 2014 · 3 comments
Open

File hash incorrectly inserted into partial filename match #40

jayhung opened this issue Jun 15, 2014 · 3 comments

Comments

@jayhung
Copy link

jayhung commented Jun 15, 2014

If a particular filename is the same as a partial part of another file, hashres is incorrectly inserting hash into the partial filename match as well.

Example:

base.min.js >> base.min.20decb81.js
angular-base.min.js >> angular-base.min.ff38c0a4.js
(partial match of "base.min.js")

Token replacement:

<script charset="utf-8" src="base.min.20decb81.js"></script><!-- correct -->
<script charset="utf-8" src="//angular-base.min.20decb81.js"></script><!-- incorrect -->

Second replacement should be

<script charset="utf-8" src="//angular-base.min.ff38c0a4.js"></script>

@bprodoehl
Copy link

I'm seeing this as well with 0.4.1. I'm not sure why it wasn't fixed by this PR, though:

#33

@gkcgautam
Copy link

@Luismahou Any update on this? This has become a major problem for us.

@yanivefraim
Copy link

@Luismahou I tried to solved this issue by changing this line:
destContents = destContents.replace(new RegExp(utils.preg_quote(value[0])+"(?[0-9a-z]+)?", "g"), value[1]);

to become:
destContents = destContents.replace(new RegExp("(?:(["'/]))" + utils.preg_quote(value[0])+"(?[0-9a-z]+)?", "g"), value[1]);

This solved the issue of mobile-main.js and main.js being treated the same. But!, this caused some testing to fall. I'm not sure why (I guess I'm not familiar with all hashres capabilities and I screwed something). Any idea? (Anyway, I am still working on trying to fix this issue (:

tnx!

yanivefraim pushed a commit to yanivefraim/grunt-hashres that referenced this issue Jan 24, 2015
Partial file names. Added regex fix in order to  match only exact file
names (So when wanting to match “main.js” only “scripts/main.js” will
fit and “scripts/mobile-main.js” will not fit). +Added unitests.
andreiashu pushed a commit to Fluxusio/grunt-hashres that referenced this issue Apr 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants