From 0740bc79aa8499314ae8d61277d05ec6ddb78e8d Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sun, 6 Nov 2022 22:36:53 -0600 Subject: [PATCH] Auto convert shortlinks to lower case --- src/main/java/tk/draganczuk/url/Routes.java | 2 ++ src/main/resources/public/index.html | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/tk/draganczuk/url/Routes.java b/src/main/java/tk/draganczuk/url/Routes.java index f4477a5..91a780b 100644 --- a/src/main/java/tk/draganczuk/url/Routes.java +++ b/src/main/java/tk/draganczuk/url/Routes.java @@ -29,6 +29,7 @@ public class Routes { split[1] = Utils.randomString(); } String shortUrl = split[1]; + shortUrl = shortUrl.toLowerCase(); if (Utils.validate(shortUrl)) { return urlRepository.addUrl(longUrl, shortUrl); @@ -41,6 +42,7 @@ public class Routes { public static String goToLongUrl(Request req, Response res) { String shortUrl = req.params("shortUrl"); + shortUrl = shortUrl.toLowerCase(); var longUrlOpt = urlRepository .findForShortUrl(shortUrl); diff --git a/src/main/resources/public/index.html b/src/main/resources/public/index.html index 30a8d3e..0e6b942 100644 --- a/src/main/resources/public/index.html +++ b/src/main/resources/public/index.html @@ -31,6 +31,10 @@ line-height: 25px; overflow: scroll; } + + form input[name="shortUrl"] { + text-transform: lowercase; + } @@ -47,7 +51,7 @@
+ pattern="[A-Za-z0-9_-]+" />