toRegistryPath method

String toRegistryPath({
  1. bool topLevel = false,
})

Implementation

String toRegistryPath({bool topLevel = false}) {
  String path = toPath();

  if (path.trim() == "/") {
    return "/";
  }

  // Strip out query params
  if (path.contains("?")) {
    path = path.split("?").first;
  }

  // Get registry key only
  if (path.contains("/")) {
    path = path.split("/").last;
  }

  return "${topLevel ? "/" : ""}$path";
}