@micro-router
    Preparing search index...

    Interface Path<Pathname, Data>

    interface Path<Pathname extends string = string, Data extends ValidData = any> {
        _data: Data;
        captures: number;
        path: Pathname;
        make(data: Data): string;
        match(input: string): MatchResult<Data>;
    }

    Type Parameters

    • Pathname extends string = string
    • Data extends ValidData = any
    Index

    Properties

    Methods

    Properties

    _data: Data
    captures: number

    The number of dynamic data captures in this path pattern.

    Static paths have 0 captures (e.g., path("/message/inbox")) Dynamic paths have 1+ captures (e.g., path("/users", string("id")) has 1)

    This is useful for route specificity comparison: When multiple routes match the same input with equal remaining text, the route with fewer captures should be preferred as it is more specific.

    const static = path("/message/inbox");        // captures: 0
    const dynamic = path("/message", string("id")); // captures: 1

    // Both match "/message/inbox", but static route should win
    // because it has fewer captures (more specific)
    path: Pathname

    Methods

    • Generates a URL path from the provided data.

      Parameters

      • data: Data

        The data to use for generating the path

      Returns string

      The generated URL path string

    • Attempts to match this path pattern against the input string.

      Parameters

      • input: string

        The URL path to match against

      Returns MatchResult<Data>

      A MatchResult indicating success or failure with extracted data