Skip to content

Commit

Permalink
Merge pull request #36 from sparsetech/feat/manual
Browse files Browse the repository at this point in the history
Manual: Add example for encoding/decoding URI values
  • Loading branch information
tindzk authored Jul 9, 2019
2 parents f7c9d31 + 793dc83 commit 1694222
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions manual/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ Define a custom codec that can be used in arguments, parameters and fragments:

Define a custom path element type:
<listing id="custom-path-elem">

Encode and decode [URI values](https://en.wikipedia.org/wiki/Percent-encoding):
<listing id="uri-values">
5 changes: 5 additions & 0 deletions manual/listings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"uri-values" : {
"code" : "val encoded = URI.encode(\"äöü\")\nprintln(encoded)\nprintln(URI.decode(encoded))",
"language" : "scala",
"result" : "%C3%A4%C3%B6%C3%BC\näöü"
},
"map" : {
"code" : "println(details.parse(\"/details/42\"))",
"language" : "scala",
Expand Down
5 changes: 5 additions & 0 deletions manual/src/main/scala/trail/manual/Listings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ object Listings extends App {

println((Root / Foo("asdf")).url(()))

listing("uri-values")
val encoded = URI.encode("äöü")
println(encoded)
println(URI.decode(encoded))

end()
write("manual/listings.json")
}

0 comments on commit 1694222

Please sign in to comment.