Skip to content

Commit

Permalink
fix #1034 Parse empty string in inferred routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jand42 committed Oct 30, 2018
1 parent 1f1c37a commit 16c643c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/sitelets/WebSharper.Sitelets/InferredRouter.fs
Expand Up @@ -181,11 +181,12 @@ module internal ServerInferredOperators =
path.Segments <- t
Some (box s)
| _ -> None
| _ -> None
| [] ->
Some (box "")
IWrite = fun (w, value) ->
if isNull value then
w.NextSegment().Append("null") |> ignore
else
elif unbox value <> "" then
w.NextSegment().Append(StringEncoding.write (unbox value)) |> ignore
IExplicitMethods = Set.empty
}
Expand Down
3 changes: 2 additions & 1 deletion src/sitelets/WebSharper.Sitelets/Router.fs
Expand Up @@ -1222,7 +1222,8 @@ module RouterOperators =
| Some s ->
Seq.singleton ({ path with Segments = t }, s)
| _ -> Seq.empty
| _ -> Seq.empty
| [] ->
Seq.singleton (path, "")
Write = fun value ->
Some (Seq.singleton (Route.Segment (if isNull value then "null" else StringEncoding.write value)))
}
Expand Down
2 changes: 2 additions & 0 deletions tests/WebSharper.Web.Tests/Routers.fs
Expand Up @@ -107,6 +107,7 @@ module PerformanceTests =
URoot
USubAction Sub1
USubAction (Sub2 "x")
UString ""
UString "hello"
UString """{} ## @!~~ +++ fe öüóőúéáű /\ `$%^&* ->%20<- .,;"""
UQuery "hello"
Expand Down Expand Up @@ -155,6 +156,7 @@ module PerformanceTests =

let ExtraTestValues =
[
UString "", "/string"
UString "xx", "/stringtoo/xx"
UCSharp (new CSharpEndPointRoot()), "/csharp/home"
UCSharp (new CSharpEndPointRoot.Sub1(X = 42)), "/csharp/sub1full/42"
Expand Down

0 comments on commit 16c643c

Please sign in to comment.