Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitelet.Infer doesn't match by order of declaration #1050

Closed
ajuch opened this issue Mar 12, 2019 · 4 comments
Closed

Sitelet.Infer doesn't match by order of declaration #1050

ajuch opened this issue Mar 12, 2019 · 4 comments
Assignees

Comments

@ajuch
Copy link

ajuch commented Mar 12, 2019

The docs at https://developers.websharper.com/docs/v4.x/fs/sitelets say that "If several cases have the same EndPoint, then parsing tries them in the order in which they are declared until one of them matches:"

This is not what actually happens when I try this example:

namespace ws_router

open WebSharper
open WebSharper.Sitelets
open WebSharper.UI

type EndPoint =
    | [<EndPoint "/">] Home
    | [<EndPoint "/">] Args of string

module Site =

    [<Website>]
    let Main =
        Sitelet.Infer (fun _ endpoint ->
            match endpoint with
            | EndPoint.Home -> Content.Text "Home"
            | EndPoint.Args name -> Content.Text (sprintf "Got Args: %s" (match name with s when s = "" -> "none!" | x -> x))
        )

When I run that example and go to localhost:xxx it displays "Got Args: none!" instead of "Home". For ReST APIs it is important that that distinction works as described in the docs!

@ajuch
Copy link
Author

ajuch commented Mar 12, 2019

Using WebSharper 4.5.7.322 and .Net Core 2.2.2.

@Jand42 Jand42 added the bug label Mar 12, 2019
@Jand42
Copy link
Member

Jand42 commented Mar 12, 2019

Duplicate of #1035.

Sorry, this is indeed an unintended side effect of some optimization, I am fixing to work as documented, should have done it earlier.

@Jand42
Copy link
Member

Jand42 commented Mar 13, 2019

@ajuch Thanks for the report!
Fix is now released in https://github.com/dotnet-websharper/core/releases/tag/4.5.10.332

@Jand42 Jand42 closed this as completed Mar 13, 2019
@ajuch
Copy link
Author

ajuch commented Mar 14, 2019

@Jand42 Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants