parentPath method

Uri parentPath({
  1. String separator = "/",
})

Uri is divided by separator and moved one level up.

Uriseparatorで分割し一つ上の階層に移動します。

final path = Uri.parse("aaaa/bbbb/cccc/dddd");
final parentPath = path.parentPath(); // "aaaa/bbbb/cccc"

Implementation

Uri parentPath({String separator = "/"}) {
  if (isEmpty) {
    return this;
  }
  final path = toString().trimString(separator);
  return Uri.parse(path.replaceAll(_tail, "").trimStringRight(separator));
}