
com.avsystem.commons.rest.UrlEncoding.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-rest_2.12 Show documentation
Show all versions of commons-rest_2.12 Show documentation
AVSystem commons library for Scala
The newest version!
package com.avsystem.commons
package rest
import java.net.{URLDecoder, URLEncoder}
object UrlEncoding {
def encode(query: String, spaceAsPlus: Boolean): String = {
val res = URLEncoder.encode(query, "UTF-8")
if (spaceAsPlus) res else res.replace("+", "%20")
}
def decode(query: String, plusAsSpace: Boolean): String = {
val pre = if (plusAsSpace) query else query.replace("+", "%2B")
URLDecoder.decode(pre, "UTF-8")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy