Function createRouteExpression

Given a server route definition, this function creates a regular expression to match it: The expression replaces the routes parameters with placeholders so it can be compared with real routes.

  • Parameters

    • route: string

      The route from which the expression will be created.

    • leadingSlash: boolean = true

      Whether or not the expression should match a leading slash.

    • trailingSlash: boolean = false

      Whether or not the expression should match a trailing slash. The reason this is false by default is because these expressions are often used to match against incoming requests, and they don't have a trailing slash.

    Returns RegExp