Skip to content

Commit d8db565

Browse files
committed
Fixed comment posting logic
1 parent 2e6f8c2 commit d8db565

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/android/tests/PostPrComment.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,28 @@ private static String readStream(java.io.InputStream stream) throws IOException
381381
}
382382

383383
private static AttachmentReplacement replaceAttachments(String body, Map<String, String> urls) {
384+
// Build a case-insensitive lookup alongside the original map
385+
Map<String, String> urlsCI = new HashMap<>();
386+
for (Map.Entry<String, String> e : urls.entrySet()) {
387+
if (e.getKey() != null && e.getValue() != null) {
388+
urlsCI.put(e.getKey().toLowerCase(), e.getValue());
389+
}
390+
}
391+
384392
Pattern pattern = Pattern.compile("\\(attachment:([^\\)]+)\\)");
385393
Matcher matcher = pattern.matcher(body);
386394
StringBuffer sb = new StringBuffer();
387395
List<String> missing = new ArrayList<>();
388396
while (matcher.find()) {
389397
String name = matcher.group(1);
398+
if (name != null) {
399+
name = name.trim();
400+
}
390401
String url = urls.get(name);
402+
if (url == null && name != null) {
403+
// try case-insensitive match
404+
url = urlsCI.get(name.toLowerCase());
405+
}
391406
if (url != null) {
392407
matcher.appendReplacement(sb, Matcher.quoteReplacement("(" + url + ")"));
393408
} else {

0 commit comments

Comments
 (0)