Handle path arrays with empty components correctly

Related: #304
This commit is contained in:
embeddedt 2023-11-23 10:11:45 -05:00
parent a1f3300a8a
commit 2946b3a7b5

View File

@ -61,6 +61,13 @@ public class CachedResourcePath {
* DOES NOT INTERN!
*/
public CachedResourcePath(String[] pathComponents) {
for(String s : pathComponents) {
if(s.length() == 0) {
// reconstruct the whole array skipping blanks. inefficient, but should not be the common case
pathComponents = Arrays.stream(pathComponents).filter(comp -> comp.length() > 0).toArray(String[]::new);
break;
}
}
this.pathComponents = pathComponents;
}