Closed dthume closed 9 years ago
Could someone please merge this and make a new release? This patch would fix this plugin and make it usable in Windows too. Right now it doesn't work at all.
Why does the replacement need four slashes? "\\\\\\\\"
becomes \\\\
after Java has parsed it, which becomes \\
after Javascript has parsed it. Shouldn't it be \
at that point?
Didn't dig into the "why" part but confirmed the patch works correctly on Windows 7. If using less backslashes (eg. \\\\
which would translate to just single \
in javascript) the plugin does not work correctly. To function properly one needs to use eight backslashes like dthume uses in his patch.
Most likely LessCSS uses the path internally in such a way that it is required to pass the path with quoted backslashes.
The large number of backslashes are required because there are 3 levels of escaping at work: regular Java string escapes, regular JavaScript string escapes, and Java regular expression replacement syntax.
So the \\\\\\\\
becomes \\\\
after Java string escaping is applied, which is what the regular expression replace method sees, causing it to add \\
in place of each original \
in the input string. The resulting string is passed to JavaScript, where it finally becomes \
after JavaScript string escaping is applied.
New version works perfectly, thanks! A friendly reminder though: you forgot to update the readme with the new version number. People will most likely use the version described there as the dependency.
This patch adds support for backslashes in resource paths, which primarily allows the plugin to work on windows. The crazy number of backslashes in the replacement string is because of the Java
String.replaceAll
syntax. Also fixes #5.