Static Resource: Index.html is not found on deployed build
reverted to version prior to 1st Apr 2019
@@ -104,17 +104,12 @@ public class StaticResourcesEndpoint implements Endpoint {
* @param resolvedPath - the resolved path to the resource we are serving
*/
private void addCacheHeadersIfNeeded(Response response, String resolvedPath) {
- if (!isHtml(resolvedPath)) {
+ if (! resolvedPath.endsWith(".html")) {
response.header(HttpHeader.CACHE_CONTROL.toString(), CACHE_MAX_AGE_VALUE);
}
}
- private boolean isHtml(String path) {
- return lower(path).endsWith(".html");
- }
-
-
/**
* index.html need to have a <base href="/[site_context]/" /> tag in the head section to ensure
* html5 mode works correctly in AngularJS. This method will ensure the existing <base href="/" /> tag
@@ -176,20 +171,18 @@ public class StaticResourcesEndpoint implements Endpoint {
URL resource = classLoader.getResource(resourcePath);
if (resource == null) {
- return isHtml(path)
- ? indexPath
- : null;
- } else {
- String resolvedPath = resource
- .getPath();
+ // 404: return index.html
+ resource = classLoader.getResource(indexPath);
+ resourcePath = indexPath;
+ }
- boolean isDirectory = resolvedPath
+ boolean isDirectory = resource
+ .getPath()
.endsWith("/");
return isDirectory
- ? resolvedPath + "/index.html"
- : resolvedPath;
- }
+ ? resourcePath + "/index.html"
+ : resourcePath;
}
}
