From f60d5f21147c1263dce4091a91a4996da1eb0565 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 4 Jun 2024 19:22:56 +0100 Subject: [PATCH] maybe order matters? --- .../backend/controller/IndexController.java | 18 +++++++++--------- src/main/resources/static/assets/script.js | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/cc/fascinated/backend/controller/IndexController.java b/src/main/java/cc/fascinated/backend/controller/IndexController.java index b97abd2..bf71ef5 100644 --- a/src/main/java/cc/fascinated/backend/controller/IndexController.java +++ b/src/main/java/cc/fascinated/backend/controller/IndexController.java @@ -26,6 +26,15 @@ public class IndexController { this.pasteService = pasteService; } + /** + * This is to allow for Hastebin compatibility. + */ + @PostMapping(value = "/documents") + public ResponseEntity uploadPaste(@RequestBody String content, @RequestHeader(HttpHeaders.CONTENT_TYPE) String contentType) { + String id = pasteService.createPaste(content, contentType); + return ResponseEntity.ok(Map.of("key", id)); + } + @GetMapping(value = "/") public String home() { return "index"; @@ -55,13 +64,4 @@ public class IndexController { return "redirect:/"; } } - - /** - * This is to allow for Hastebin compatibility. - */ - @PostMapping(value = "/documents") - public ResponseEntity uploadPaste(@RequestBody String content, @RequestHeader(HttpHeaders.CONTENT_TYPE) String contentType) { - String id = pasteService.createPaste(content, contentType); - return ResponseEntity.ok(Map.of("key", id)); - } } diff --git a/src/main/resources/static/assets/script.js b/src/main/resources/static/assets/script.js index 82bbe33..a1f3c6b 100644 --- a/src/main/resources/static/assets/script.js +++ b/src/main/resources/static/assets/script.js @@ -32,7 +32,7 @@ const upload = async () => { throw new Error(data.message); } - window.location.href = "/" + data.id; + window.location.href = "/" + data.key; } catch (error) { console.error("Error:", error); toast(`${error.message || "An error occurred while uploading the paste."}`);