summaryrefslogtreecommitdiff
path: root/server/test/src/URIUtilsSpec.scala
diff options
context:
space:
mode:
authorJuan J. Martínez <jjm@usebox.net>2022-01-20 21:44:34 +0000
committerJuan J. Martínez <jjm@usebox.net>2022-01-20 21:44:34 +0000
commitf90e7bad9f1df2d652b82048e9073096ddc8df18 (patch)
treec6f53976dfcb03cabf474a9c8528db44da762c2e /server/test/src/URIUtilsSpec.scala
parent397bee70a0baa6ab7cc2115c3a5dd555b381a49d (diff)
parentaee32d5f42560ad0ff5d47034da699b3e608d2b4 (diff)
downloadspacebeans-f90e7bad9f1df2d652b82048e9073096ddc8df18.tar.gz
spacebeans-f90e7bad9f1df2d652b82048e9073096ddc8df18.zip
Merge branch 'protocol-refactor' into 'main'
Protocol refactor See merge request reidrac/spacebeans!2
Diffstat (limited to 'server/test/src/URIUtilsSpec.scala')
-rw-r--r--server/test/src/URIUtilsSpec.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/server/test/src/URIUtilsSpec.scala b/server/test/src/URIUtilsSpec.scala
new file mode 100644
index 0000000..ab00c86
--- /dev/null
+++ b/server/test/src/URIUtilsSpec.scala
@@ -0,0 +1,26 @@
+package net.usebox.gemini.server
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+import URIUtils._
+
+class URIUtilsSpec extends AnyFlatSpec with Matchers {
+
+ behavior of "validPath"
+
+ it should "return true for the emtpy path" in {
+ "".isValidPath shouldBe true
+ }
+
+ it should "return true for valid paths" in {
+ List("/", "/file", "/./", "/.", "/dir/", "/dir/../").foreach(
+ _.isValidPath shouldBe true
+ )
+ }
+
+ it should "return false for invalid paths" in {
+ List("/../", "/..", "/dir/../..", "/dir/../..", "/./../", "/./dir/.././../")
+ .foreach(_.isValidPath shouldBe false)
+ }
+}