aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/net/usebox/gemini/server/Server.scala4
-rw-r--r--server/test/src/ServerSpec.scala7
2 files changed, 10 insertions, 1 deletions
diff --git a/server/src/net/usebox/gemini/server/Server.scala b/server/src/net/usebox/gemini/server/Server.scala
index ce840df..5b1692f 100644
--- a/server/src/net/usebox/gemini/server/Server.scala
+++ b/server/src/net/usebox/gemini/server/Server.scala
@@ -72,7 +72,9 @@ case class Server(conf: ServiceConf) {
uri.getScheme(),
uri.getHost(),
uri.getPath().decode(),
- vHosts.find(_.host == uri.getHost().toLowerCase)
+ vHosts.find(vh =>
+ Some(vh.host) == Option(uri.getHost()).map(_.toLowerCase)
+ )
) match {
case (null, _, _, _) =>
logger.debug(s"no scheme")
diff --git a/server/test/src/ServerSpec.scala b/server/test/src/ServerSpec.scala
index c9a6947..dd6bf20 100644
--- a/server/test/src/ServerSpec.scala
+++ b/server/test/src/ServerSpec.scala
@@ -171,6 +171,13 @@ class ServerSpec extends AnyFlatSpec with Matchers {
)
}
+ it should "return bad request on empty URLs" in {
+ Server(TestData.conf)
+ .handleReq("", "127.0.0.1") should be(
+ a[BadRequest]
+ )
+ }
+
it should "return bad request when the path is out of root dir" in {
Server(TestData.conf)
.handleReq("gemini://localhost/../../", "127.0.0.1") should be(