Bolero brings Blazor to F# developers with an easy to use Model-View-Update architecture, HTML combinators, hot reloaded templates, type-safe endpoints, advanced routing and remoting capabilities, and more.
Suppose router:Router<Route, _, _> is generated by Router.infer:
type Route =
| [<EndPoint("/")>] Default
| [<EndPoint("/{value}")>] Value of value:string
type Message =
| SetPage of Route
type Model = { Page: Route }
let router = Router.infer SetPage (fun model -> model.Page)
When users access to non-ASCII endpoint such as /日本語, the passed URL path to Value endpoint may be URL-encoded as /%E6%97%A5%E6%9C%AC%E8%AA%9E by their web browser. It is not easy to use because I need to decode every time when I use URL path parameter.
let update message model =
match message with
| SetPage(page) -> { model with Page = page }
let view model dispatch =
AppTemplate()
.ContentsByPage(
Html.cond model.Page <| function
| Default -> (* ... *)
| Value(value) -> (* value is URL encoded here *)
)
When an encoded path parameter is referred in update function via message and passed to remote server without explicit decode on client-side, the remote server will receive URL-encoded string in JSON and it could be the cause of a bug.
Suggestion
My suggestion is that the passed URL paths by router generated by Router.infer are always URL-decoded. I think it is tough task to make a custom router to avoid that problem.
Problem
Suppose
router:Router<Route, _, _>
is generated byRouter.infer
:When users access to non-ASCII endpoint such as
/日本語
, the passed URL path toValue
endpoint may be URL-encoded as/%E6%97%A5%E6%9C%AC%E8%AA%9E
by their web browser. It is not easy to use because I need to decode every time when I use URL path parameter.When an encoded path parameter is referred in
update
function via message and passed to remote server without explicit decode on client-side, the remote server will receive URL-encoded string in JSON and it could be the cause of a bug.Suggestion
My suggestion is that the passed URL paths by router generated by Router.infer are always URL-decoded. I think it is tough task to make a custom router to avoid that problem.