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 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 include karax/prelude
import jester/[patterns] import jester/[patterns]
@ -87,7 +87,13 @@ proc render(): VNode =
), ),
r("/profile/@username", r("/profile/@username",
(params: Params) => (params: Params) =>
(render(state.profile, params["username"], getLoggedInUser())) (
render(
state.profile,
decodeURI(params["username"]),
getLoggedInUser()
)
)
), ),
r("/t/@id", r("/t/@id",
(params: Params) => (params: Params) =>

View file

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