Giraffe icon indicating copy to clipboard operation
Giraffe copied to clipboard

Allowing subRoute to match full path segments

Open TheJayMann opened this issue 5 years ago • 0 comments

In some cases, I would like to be able to use subRoute* to match full path segments only, while also handling the case where the path matches exactly without a trailing /.

When including a trailing / in the path to subRoute, it will match the path segments completely, but it won't handle the case where the trailing / is omitted. Also, the new path in the provided handler will not have a leading /.

To allow this new functionality, three new handlers can be created which would coincide with the three existing handlers.

let subDirRoute path next = 
  subRoute path (
    choose [ route "" ; routeStartsWith "/" ] >=> next
  )

let subDirRouteCi path next = 
  subRouteCi path (
    choose [ route "" ; routeStartsWith "/" ] >=> next 
  )

let subDirRoutef path next = 
  subRoutef path (fun v ->
    choose [ route "" ; routeStartsWith "/" ] >=> next v
  )

TheJayMann avatar Jun 05 '19 13:06 TheJayMann