2

I am using kotlinx.html DSL to generate an HTML DIV. One of the DIV's attributes is a URL with & in it. e.g. Parameter url below is https://www.example.com?a=1&b=2

fun createDiv(url: String): DIV.() -> Unit {
  return {
    attributes["data-url"] = url
  }
}

I was hoping to generate
<div data-url="https://www.example.com?a=1&b=2">
But I am actually getting
<div data-url="https://www.example.com?a=1&amp;b=2">

How can I prevent the URL from being HTML encoded? Thanks!

P.S. I've tried unsafe. But my actual DIV is a bit too complex to be put into an unsafe construct as a string. I am using Kotlin 1.4.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.