parse static method

SubstratePath parse(
  1. String path
)

Parses the input path and constructs a SubstratePath object.

The path should be a string representation of a Substrate path. Throws a SubstratePathError if the path is invalid.

Implementation

static SubstratePath parse(String path) {
  if (path.isNotEmpty && !path.startsWith('/')) {
    throw SubstratePathError('Invalid path ($path)');
  }

  /// Extract path elements using a regular expression and create a SubstratePath object.
  final paths = RegExp(SubstratePathConst.rePath)
      .allMatches(path)
      .map((match) => match.group(0)!)
      .toList();
  return SubstratePath(paths.map((e) => SubstratePathElem(e)).toList());
}