Represents a deep link that can be deep linked into when matched with a DeepLinkRequest

If the matcher constructed with this overload matches a DeepLinkRequest, the provided serializer will be used to instantiate the deep link target's navigation key.

T The type of the navigation key associated with this deep link.

Supported Path patterns and extracted argument examples

  1. Exact Path

    • Pattern: www.example.com/users

    • Arguments: https://www.example.com/users

    • Extracted values: Extracts no arguments.

  2. Single placeholder

    • Pattern: www.example.com/users/{id}

    • Arguments: Extracts argument ["id"].

    • Request: https://www.example.com/users/123

    • Extracted values: Maps "id" to "123".

  3. Multiple placeholders

    • Pattern: www.example.com/users/{first}-{last}

    • Arguments: Extracts arguments "first", "last".

    • Request: https://www.example.com/users/john-doe

    • Extracted values: Maps "first" to "john" and "last" to "doe".

  4. Wildcard

    • Pattern: www.example.com/users/.*

    • Arguments: Extracts no arguments.

  5. Mixed literal and placeholder

    • Pattern: www.example.com/users/user_{id}

    • Arguments: Extracts argument "id".

    • Request: https://www.example.com/users/user_123

    • Extracted values: Maps "id" to "123".

  6. Empty String

    • Pattern: www.example.com/users/{id}/profile

    • Arguments: Extracts argument "id".

    • Request: www.example.com/users//profile

    • Extracted values: Maps "id" to "".

Supported Query Pattern Types and Examples

  1. Named Parameter

    • Pattern: ?name={name}

    • Arguments: Extracts argument "name".

    • Request: ?name=john

    • Extracted values: Maps "name" to "john".

  2. Unnamed Parameter

    • Pattern: ?{rawQuery}

    • Arguments: Extracts argument "rawQuery".

    • Request: ?anything&else

    • Extracted values: Maps "rawQuery" to "anything", "else".

  3. Partial Literal Matching

    • Pattern: ?type=user_{id}

    • Arguments: Extracts argument "id".

    • Request: ?type=user_123

    • Extracted values: Maps "id" to "123".

  4. Multiple Placeholders in One Parameter

    • Pattern: ?name={first}_{last}

    • Arguments: Extracts arguments "first", "last".

    • Request: ?name=john_doe

    • Extracted values: Maps "first" to "john" and "last" to "doe".

  5. Collection Parameters

    • Pattern: ?list={list}

    • Arguments: Extracts argument "list".

    • Request: ?list=10&list=20

    • Extracted values: Maps "list" to "10", "20".

  6. Wildcard Matching

    • Pattern: ?type=user_.*

    • Arguments: Extracts argument "type".

    • Request: ?type=user_admin

    • Extracted values: Maps "type" to "admin".

  7. Mixed Named and Unnamed Parameters

    • Pattern: ?user={name}&{other}

    • Arguments: Extracts arguments "name", "other".

    • Request: ?user=john&something

    • Extracted values: Maps "name" to "john" and "other" to "something".

Unsupported Query Pattern Types and Examples

  1. Repeated Parameter Names in Pattern

    • Pattern: www.example.com?name={first}&name={last}

  2. Extra Parameters

    • Pattern: ?name={name}

    • Arguments: Extracts arguments "name".

    • Request: ?name=john&city=someCity

    • Extracted values: Maps "name" to "john". // city is ignored

  3. Multiple Unnamed Parameters in Pattern

    • Pattern: ?{arg1}&{arg2}

Supported Fragment Pattern Types and Examples

  1. Static Fragment

    • Pattern: #section1

    • Arguments: None

    • Request: #section1

    • Extracted values: None extracted.

  2. Single Placeholder

    • Pattern: #section_{id}

    • Arguments: Extracts argument "id".

    • Request: #section_123

    • Extracted values: Maps "id" to "123".

  3. Wildcard

    • Pattern: #section_.*

    • Arguments: Extracts argument "section".

    • Request: #section_123

    • Extracted values: Maps "section" to "123".

Summary

Public constructors

<T : Any> UriDeepLinkMatcher(
    uriPattern: DeepLinkUri,
    serializer: KSerializer<T>,
    filters: List<DeepLinkMatcher.Filter<Any>>
)
Cmn

Protected functions

open UriMatchResult<T>?
matchArguments(
    pathArgs: Map<StringList<String>>,
    queryArgs: Map<StringList<String>>,
    fragmentArgs: Map<StringList<String>>
)

Matches the argument values extracted from DeepLinkRequest.uri and instantiates a T instance with the provided serializer and extracted values.

Cmn
open UriMatchResult<T>?

Matches this matcher against a DeepLinkRequest.

Cmn
open UriMatchResult<T>?

Matches this UriDeepLinkMatcher against a DeepLinkRequest.uri.

Cmn

Public constructors

UriDeepLinkMatcher

<T : Any> UriDeepLinkMatcher(
    uriPattern: DeepLinkUri,
    serializer: KSerializer<T>,
    filters: List<DeepLinkMatcher.Filter<Any>> = emptyList()
)
Parameters
uriPattern: DeepLinkUri

The DeepLinkUri containing the uri pattern that this matcher supports.

serializer: KSerializer<T>

The serializer to instantiate an instance of T

filters: List<DeepLinkMatcher.Filter<Any>> = emptyList()

an optional list of filters to filter a DeepLinkRequest when matching

Protected functions

matchArguments

protected open fun matchArguments(
    pathArgs: Map<StringList<String>> = emptyMap(),
    queryArgs: Map<StringList<String>> = emptyMap(),
    fragmentArgs: Map<StringList<String>> = emptyMap()
): UriMatchResult<T>?

Matches the argument values extracted from DeepLinkRequest.uri and instantiates a T instance with the provided serializer and extracted values.

Parameters
pathArgs: Map<StringList<String>> = emptyMap()

The extracted path arguments. Empty if no values were extracted.

queryArgs: Map<StringList<String>> = emptyMap()

The extracted query arguments. Empty if the uri contains no query or no values were extracted.

fragmentArgs: Map<StringList<String>> = emptyMap()

The extracted fragment arguments. Empty if the uri contains no fragment or no values were extracted.

Returns
UriMatchResult<T>?

A UriMatchResult containing the navigation key T and extracted arguments if matched, null otherwise.

matchRequest

protected open fun matchRequest(request: DeepLinkRequest): UriMatchResult<T>?

Matches this matcher against a DeepLinkRequest.

Match succeeds if:

  • request passes all the provided filters

  • can successfully instantiate a T instance with the serializer based on the provided arguments extracted from the request

Parameters
request: DeepLinkRequest

The deep link request to match.

Returns
UriMatchResult<T>?

A UriMatchResult containing the navigation key T and extracted arguments if matched, null otherwise.

matchUri

protected open fun matchUri(uri: DeepLinkUri): UriMatchResult<T>?

Matches this UriDeepLinkMatcher against a DeepLinkRequest.uri.

It checks for scheme, authority, and path segment count. If they match, proceeds to extract all argument values from the DeepLinkRequest.uri.

Parameters
uri: DeepLinkUri

The requested DeepLinkUri to match with.

Returns
UriMatchResult<T>?

A UriMatchResult containing the navigation key T and extracted arguments if matched, null otherwise.