-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong replacements in targets file #4
Comments
After some testing I managed to identify the bug. In the following minimal working examples (MWE) I will use the command MWE 1
with
This works. MWE 2
with
This doesn't work. Both relative paths get the same hash. Solution for MWE 2 In line 126-133
we can see that you search for
To illustrate the last point:
The search/replace order should be:
Additional information Of course the .jpg files in the examples above have only the same name but they look different - otherwise they would generate the same hash. MWE 3
with
This doesn't work. Both relative paths get the same hash. Solution for MWE 3 With line 73
you solve the issue
but it doesn't solve the issue
Idea 1 I think you can delete this line and solve the issue if you add to your regex in line 129
the delimiters of the path. For example instead of searching for I am not very happy with my solution because there are more delimiters and sometimes there are no delimiters (if the file name is mentioned in plain text for example). Idea 2 Let's look at the following example:
with
we get this order
The problem is if we search for
Summary Fix for MWE 2
On each hierarchy level we have to.... Fix for MWE 3
Test case
with
(Of course the .jpg files in the example above have only the same name but they look different - otherwise they would generate the same hash.) |
In my test case above I forgot that there are absolute and relative path on all hierarchy levels. Test case (Updated)
with
with
with
|
Thanks a lot for the great explanation of the problem and solution proposals. This will be prioritized in the following version I release. As you mention, sorting the array was not an integral solution to the problem. I already thought on the delimiters idea, but abandoned it for the same reason, it was more a dirty workaround than a solution. Haven't had time to analyze your findings in depth, but grouping by character count and replacing starting with the longest to the shortest group looks like a good idea. Thanks again! Of course, PRs are always welcome! |
Steps to reproduce the bug
Download one page of my website and all its assets with the command
wget -E -k -K -p https://www.mathebibel.de
Open the folder
ẁww.mathebibel.de
and run the commandcachekill -l 16 -r -p '{name}.{hash}{ext}' -s '**/*.{svg,jpg,jpeg,png,ico,ttf,woff,woff2}' -t '**/*.{html,css,js,webmanifest}'
Open the file
index.html
and search forda5a9c97d2054b2a
.You will get the following 6 hits:
bilder/logo.da5a9c97d2054b2a.png
awards/gpi-logo.da5a9c97d2054b2a.png
awards/stern-logo.da5a9c97d2054b2a.png
awards/ntv-logo.da5a9c97d2054b2a.png
bilder/logo.da5a9c97d2054b2a.png
bilder/easy-tutor-logo.da5a9c97d2054b2a.png
Number 1 and 5 are correct replacements. Number 2, 3, 4 and 6 are wrong replacements.
This was just an example. You can find even more wrong replacements in the
index.html
.The text was updated successfully, but these errors were encountered: