Skip to content

How to handle hash in Routing.Match #60

@rnons

Description

@rnons

I have a route like this

myRoute =
  root *> oneOf
  [ RegionRoute <$> (lit "region" *> regionMatcher)
  ]

data Region = West | East

regionMatcher :: Match Region

When using Routing.PushState.matches, /region/west will match, but /region/west#hash will fail. I understand my regionMatcher failed to parse west#hash as Region.

I ended up dropping the hash before hand.
myMatch = matchesWith <<< matchWith (unsafeDecodeURIComponent <<< String.takeWhile (_ /= String.codePointFromChar '#'))

Wondering is there a better way to handle this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions