-
Notifications
You must be signed in to change notification settings - Fork 3
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
Inconsistent behaviour in path
and fullPath
#18
Comments
Thanks for opening this new issue to discuss this. There probably isn't a good way to do this but I wish we could prohibit the use of a version in the |
Well, as you said, there is no (good) reason for the user to provide a version in the incoming parameters, as determining the version is exactly what the WebJars locator is for. We had some trainee wo used webjars but added the path including the version, but in my opinion it is ok, to "fail" in a case like this. At least in Spring based projects When the template contains the version like This would cause a 404 during development allowing to fix it early. when the locator ignores the 4.7.0 the output would become In my opinion, the check should be removed to avoid this kind delayed fails. Assuming the check gets removed, I also would avoid adding any other check for versions in the path. While it might me a strange edge case, but what if the webjar structure is actually somewhat like |
That makes sense. I'm all for enabling better and earlier error messages. |
As mentioned in #13 (comment), i found that
fullPath
andpath
have slightly inconsitent behaviour for cases whereexactPath
starts with the version.In such cases,
path
could return a path with the version contained twice. Once from the String format arguments, and once from it beeing contained inexactPath
.fullPath
on the other hand check for the version beeing part (startsWith) of theexactPath
and in that case not including the version again in the String format call. AlthoughfullPath
has a TODO comment questioning the need for that check.For me using the WebJars locator only indirectly with Spring, only the fullPath seems to be used. And as I do not have deeper knowledge about the API I can't tell if this is by any means can be a problem for other use cases.
Regarding the question in the TODO comment, i would suggest
keeping the check (and potentially add it to. On the other hand, this could cause some false security on the developer side... as it then fails when updating the webjar and not already at the time of adding...path
). The reason for this is, that I saw cases, where the full path, including the version, has been used in the a thymeleaf template. With this check the locator gracefully handles this kind of "invalid" usage instead of having the version twiceOkay, as of writing and thinking a bit more about this. Maybe the check should be removed, to fail early when adding the webjar instead of only failing after updating it?
What are your thoughts on this?
The text was updated successfully, but these errors were encountered: