Repository: Stirling-Tools/Stirling-PDF
File: app/core/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java (Java)

Code before:
                    Map<String, PDActionJavaScript> jsEntries = jsTree.getNames();

                    for (Map.Entry<String, PDActionJavaScript> entry : jsEntries.entrySet()) {
                        String name = entry.getKey();
                        PDActionJavaScript jsAction = entry.getValue();
                        String jsCodeStr = jsAction.getAction();

                        if (jsCodeStr != null && !jsCodeStr.trim().isEmpty()) {
                            script.append("// File: ")
                                .append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
                                .append(", Script: ")
                                .append(name)
                                .append("\n")
                                .append(jsCodeStr)
                                .append("\n");
                            foundScript = true;
                        }
                    }
                }
            }

            if (!foundScript) {
                script.setLength(0);
                script.append("PDF '")
                    .append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
                    .append("' does not contain Javascript");
            }

            return WebResponseUtils.bytesToWebResponse(
                    script.toString().getBytes(StandardCharsets.UTF_8),
                    Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + ".js",
                    MediaType.TEXT_PLAIN);
        }
    }
}


Review comment (suggestion):
Wouldn't it be better?

```java

new StringBuilder("PDF '")
.append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
.append("' does not contain Javascript");
```

Code after:
                    Map<String, PDActionJavaScript> jsEntries = jsTree.getNames();

                    for (Map.Entry<String, PDActionJavaScript> entry : jsEntries.entrySet()) {
                        String name = entry.getKey();
                        PDActionJavaScript jsAction = entry.getValue();
                        String jsCodeStr = jsAction.getAction();

                        if (jsCodeStr != null && !jsCodeStr.trim().isEmpty()) {
                            script.append("// File: ")
                                .append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
                                .append(", Script: ")
                                .append(name)
                                .append("\n")
                                .append(jsCodeStr)
                                .append("\n");
                            foundScript = true;
                        }
                    }
                }
            }

            if (!foundScript) {
                script = new StringBuilder("PDF '")
                    .append(Filenames.toSimpleFileName(inputFile.getOriginalFilename()))
                    .append("' does not contain Javascript");
            }

            return WebResponseUtils.bytesToWebResponse(
                    script.toString().getBytes(StandardCharsets.UTF_8),
                    Filenames.toSimpleFileName(inputFile.getOriginalFilename()) + ".js",
                    MediaType.TEXT_PLAIN);
        }
    }
}