Skip to content

Commit

Permalink
Ensure that index.html works in any directory in native mode
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Apr 4, 2024
1 parent 7095bee commit 47749d4
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ public void nativeImageResource(Optional<StaticResourcesBuildItem> staticResourc
// TODO: do we perhaps want to register the whole directory?
continue;
}
String metaInfResourcesPath = StaticResourcesRecorder.META_INF_RESOURCES + entry.getPath();
String path = entry.getPath();
int index = path.lastIndexOf("/index.html");
if (index > 0) {
// in this case we want to register the directory that contains index.html (for example static/users/index.html would register static/users)
// as a resource because the StaticHandler needs to see the directory is available in order to serve index.html
producer.produce(new NativeImageResourceBuildItem(
StaticResourcesRecorder.META_INF_RESOURCES + path.substring(0, index)));
}
String metaInfResourcesPath = StaticResourcesRecorder.META_INF_RESOURCES + path;
metaInfResources.add(metaInfResourcesPath);
}
producer.produce(new NativeImageResourceBuildItem(metaInfResources));
Expand Down

0 comments on commit 47749d4

Please sign in to comment.