I have a Thymeleaf template which has something like this:
<script id="tesseract-config" type="application/json" th:inline="text">
{
"workerPath":"[[@{/webjars/frontend/tesseract/worker/worker.min.js}]]",
"corePath":"[[@{/webjars/frontend/tesseract/core/__${tesseractCore}__}]]",
"langPath":"[[@{/webjars/frontend/tesseract/lang/}]]"
}
</script>
this template is resolved to
<script id="tesseract-config" type="application/json">
{
"workerPath":"/webjars/frontend/1.0.60/tesseract/worker/worker.min.js",
"corePath":"/webjars/frontend/1.0.60/tesseract/core/tesseract-core-lstm.wasm.js",
"langPath":"/webjars/frontend/tesseract/lang/"
}
</script>
My problem is, that the webjars path is only resolved to the correct version, where a resource was specified. Directories do not get resolved.
The issue seems to be here: https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/LiteWebJarsResourceResolver.java#L77
the resolver returns null and the original path is returned instead of the webJarResourcePath. In this concrete example, the resolver returns null because the directory is not "readable" but exists https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java#L189
That's an issue for us, because the browser requests unversioned files due to the unversioned directory, which get cached due to the cache control header.
I have a Thymeleaf template which has something like this:
this template is resolved to
My problem is, that the webjars path is only resolved to the correct version, where a resource was specified. Directories do not get resolved.
The issue seems to be here: https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/LiteWebJarsResourceResolver.java#L77
the resolver returns null and the original path is returned instead of the webJarResourcePath. In this concrete example, the resolver returns null because the directory is not "readable" but exists https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java#L189
That's an issue for us, because the browser requests unversioned files due to the unversioned directory, which get cached due to the cache control header.