Skip to content

How to handle hash in Routing.Match #60

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?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions