prefixStripper static method

DeepLinkTransformer prefixStripper(
  1. String prefix
)

Helper function to remove the prefix path of a Uri You can use this method to remove the prefix of a path the prefix should start with a /

If not able to parse the resulting Uri, return the original

Implementation

static DeepLinkTransformer prefixStripper(String prefix) {
  return (Uri uri) {
    if (!uri.path.startsWith(prefix)) {
      return SynchronousFuture(uri); // No change if prefix not found
    }
    return SynchronousFuture(
      Uri.tryParse(uri.toString().replaceFirst(prefix, '')) ?? uri,
    );
  };
}