preparePath method

List preparePath(
  1. String path
)

Prepare path

Implementation

List<dynamic> preparePath(String path) {
  List<String> parts = path.split('/').where((p) => p.isNotEmpty).toList();
  String prepare = '';
  Map<String, int> params = {};

  for (int key = 0; key < parts.length; key++) {
    String part = parts[key];
    if (key != 0) {
      prepare += '/';
    }

    if (part.startsWith(':')) {
      prepare += placeholderToken;
      params[part.substring(1)] = key;
      if (!_params.contains(key)) {
        _params.add(key);
      }
    } else {
      prepare += part;
    }
  }

  return [prepare, params];
}