fix the fix
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m2s
Publish Docker Image / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 56s

This commit is contained in:
Lee 2024-06-04 19:31:06 +01:00
parent f60d5f2114
commit 98711948b6
2 changed files with 7 additions and 7 deletions

@ -26,20 +26,20 @@ public class IndexController {
this.pasteService = pasteService;
}
@GetMapping(value = "/")
public String home() {
return "index";
}
/**
* This is to allow for Hastebin compatibility.
*/
@PostMapping(value = "/documents")
public ResponseEntity<?> uploadPaste(@RequestBody String content, @RequestHeader(HttpHeaders.CONTENT_TYPE) String contentType) {
public ResponseEntity<?> uploadPaste(@RequestBody String content, @RequestHeader(value = HttpHeaders.CONTENT_TYPE, required = false) String contentType) {
String id = pasteService.createPaste(content, contentType);
return ResponseEntity.ok(Map.of("key", id));
}
@GetMapping(value = "/")
public String home() {
return "index";
}
@GetMapping(value = "/{id}")
public String paste(@PathVariable String id, Model model) {
try {

@ -56,7 +56,7 @@ public class PasteService {
}
// Ensure the paste content type is valid.
if (contentType.contains("image") || contentType.contains("video") || contentType.contains("audio")) {
if (contentType != null && (contentType.contains("image") || contentType.contains("video") || contentType.contains("audio"))) {
log.info("Paste content type is not supported. (content type: {})", contentType);
throw new BadRequestException("The paste content type is not supported, not uploading...");
}