Fix url encoding to encode whitespace to %20

This commit is contained in:
Naoki Takezoe
2015-10-03 04:00:08 +09:00
parent 6e994b0ae1
commit 73cf9661ac
2 changed files with 11 additions and 1 deletions

View File

@@ -4,11 +4,21 @@ import org.specs2.mutable._
class StringUtilSpec extends Specification {
"urlEncode" should {
"encode whitespace to %20" in {
val encoded = StringUtil.urlEncode("aa bb")
encoded mustEqual "aa%20bb"
}
}
"urlDecode" should {
"decode encoded string to original string" in {
val encoded = StringUtil.urlEncode("あいうえお")
StringUtil.urlDecode(encoded) mustEqual "あいうえお"
}
"decode en%20 to whitespace" in {
StringUtil.urlDecode("aa%20bb") mustEqual "aa bb"
}
}
"splitWords" should {