All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avsystem.commons.rest.UrlEncoding.scala Maven / Gradle / Ivy

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