Fixes profile UTF-8 decoding issue.

This commit is contained in:
Dominik Picheta 2018-05-25 21:43:41 +01:00
commit c32daefec7
2 changed files with 11 additions and 4 deletions

View file

@ -1,5 +1,5 @@
import strformat, times, options, json, tables, sugar, httpcore, uri
from dom import window, Location, document
from dom import window, Location, document, decodeURI
include karax/prelude
import jester/[patterns]
@ -87,7 +87,13 @@ proc render(): VNode =
),
r("/profile/@username",
(params: Params) =>
(render(state.profile, params["username"], getLoggedInUser()))
(
render(
state.profile,
decodeURI(params["username"]),
getLoggedInUser()
)
)
),
r("/t/@id",
(params: Params) =>

View file

@ -56,9 +56,10 @@ when defined(js):
proc render*(
state: ProfileState,
username: string,
username: kstring,
currentUser: Option[User]
): VNode =
if state.profile.isSome() and state.profile.get().user.name != username:
state.profile = none[Profile]()
state.status = Http200
@ -69,7 +70,7 @@ when defined(js):
if state.profile.isNone:
if not state.loading:
state.loading = true
let uri = makeUri("profile.json", ("username", username))
let uri = makeUri("profile.json", ("username", $username))
ajaxGet(uri, @[], (s: int, r: kstring) => onProfile(s, r, state))
return buildHtml(tdiv(class="loading loading-lg"))