getDepth static method

int getDepth(
  1. String path
)

Implementation

static int getDepth(String path) {
  path = sanitize(path);

  if (path == '/') {
    return 0;
  }

  if (!path.contains("/")) {
    return 1;
  }

  return path.split('/').length;
}