aboutsummaryrefslogtreecommitdiff
path: root/server/test/src/URIUtilsSpec.scala
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-01-16 00:22:24 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-01-16 00:22:24 +0000
commit60d4dce0193fb9d592f2fe065908bfc88da89dff (patch)
tree4a96331789a475dfbd587eaef95c4f9504081a6b /server/test/src/URIUtilsSpec.scala
parent397bee70a0baa6ab7cc2115c3a5dd555b381a49d (diff)
downloadspacebeans-60d4dce0193fb9d592f2fe065908bfc88da89dff.tar.gz
spacebeans-60d4dce0193fb9d592f2fe065908bfc88da89dff.zip
Refactor Gemini protocol
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)
+ }
+}