Skip to content

Commit

Permalink
what about this
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Dec 16, 2024
1 parent e001b0f commit b905ad2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,18 @@ public static String replaceFullGenericType(String text, BlockType blockType, Re

//pattern to find sub folders. Does not include "/"
//matches stuff between oldNamespace + folderName and oldTypeName not including leading or trailing slashes
Pattern subFolderPattern = Pattern.compile(oldNamespace + folderReg + "\\/?(.*?\\/?.*?)" + oldTypeName);
Pattern subFolderPattern = Pattern.compile(oldNamespace + folderReg + "\\/?(.*?)\\/?(.*?)" + oldTypeName);
Matcher subFolderMatcher = subFolderPattern.matcher(text);
return subFolderMatcher.replaceAll(m ->
newNamespace + joinWithSeparator(m.group(1), blockPathPrefix, m.group(2), blockPathSuffix)
newNamespace + joinWithSeparator(m.group(1), blockPathPrefix, m.group(2), m.group(3) + blockPathSuffix)
);
}

private static String joinWithSeparator(String... strings) {
StringBuilder sb = new StringBuilder();
for (String s : strings) {
if (!s.isEmpty()) {
if (!sb.isEmpty() && s.endsWith("/")) sb.append("/");
if (!sb.isEmpty()) sb.append("/");
sb.append(s);
}
}
Expand Down

0 comments on commit b905ad2

Please sign in to comment.