Potentially address subtle bug with file paths getting a trailing slash #161
+8
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new Antigravity IDE by Google and Gemini 3 Pro found this one while I was trying to write Terasology tests validating various ways to get resources. It sounded reasonable and tested out - will let the AI explain further! Leaving this in a PR just so I don't forget the what and why, it doesn't need to merge any time soon.
Explanation of the Gestalt Fix
The issue was in ClasspathFileSource.buildPathString(), which was unconditionally appending a slash (/) to the path.
Is it safe? Yes. getFile() returns a FileReference, which is intended for reading files (it has an open() method for streams). It is not typically used for directories. Even if it were, ClassLoader.getResource generally handles directory paths without trailing slashes correctly anyway. The fix simply constructs the path exactly as requested for getFile, bypassing the directory-oriented helper.
Note
Adjusts
ClasspathFileSourceto only append a trailing slash for directories, not files.ClasspathFileSource:buildPathString(List<String> path)tobuildPathString(List<String> path, boolean isDirectory).getFile(...)now callsbuildPathString(..., false)(no trailing slash for files).getFilesInPath(...)andgetSubpaths(...)now callbuildPathString(..., true)(trailing slash for directories)."/"only whenisDirectoryis true.Written by Cursor Bugbot for commit e309888. This will update automatically on new commits. Configure here.