aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/App.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/App.kt')
-rw-r--r--src/main/kotlin/App.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt
index d3f0cd9..50c7c18 100644
--- a/src/main/kotlin/App.kt
+++ b/src/main/kotlin/App.kt
@@ -11,6 +11,7 @@ import io.javalin.security.*
import io.javalin.security.SecurityUtil.roles
import io.javalin.staticfiles.*
import java.io.*
+import java.net.*
import java.util.logging.*
const val fileHome = "files"
@@ -36,6 +37,18 @@ fun main() {
app.routes {
/**
+ * Normalizes and cleans the requested url
+ */
+ before("/*") { ctx ->
+ run {
+ if (URI(ctx.url()).normalize().toString() != ctx.url()) {
+ log.warning("Normalized url from ${ctx.url()} to ${URI(ctx.url()).normalize()}")
+ ctx.redirect(URI(ctx.url()).normalize().toString())
+ }
+ }
+ }
+
+ /**
* Main page
* TODO: Create landing page
*/