x4js - v2.2.49
    Preparing search index...

    Function parseRoute

    • Parses a route string or regular expression into a Segment object. This function converts human-readable route patterns (e.g., '/users/:id') into a regular expression that can be used for matching URL paths, and extracts parameter names.

      Parameters

      • str: string | RegExp

        The route pattern as a string (e.g., '/users/:id') or a direct RegExp object.

      • loose: boolean = false

        If true, the pattern will match paths that start with the route but may have additional segments. If false (default), the pattern must match the entire path.

      Returns Segment

      A Segment object containing the extracted keys and the compiled regular expression.