public int getDepth() {
        int colonIndex = uri.indexOf(':');

        // count number of slashes in the Uri
        int currentIndex = colonIndex;
        int depth = 0;

        while (currentIndex != -1) {
            currentIndex = uri.indexOf('/', currentIndex);
            if (currentIndex != -1) {
                depth++;
                currentIndex++;
            }
        }

        if (uri.charAt(colonIndex + 1) == '/') {
            depth--;
        }
        if (uri.charAt(colonIndex + 2) == '/') {
            depth--;
        }
        if ((uri.charAt(uri.length() - 1) == '/')
                && ((uri.length() - 1) > (colonIndex + 2))) {
            depth--;
        }
        return depth;
    }
Returns the depth of this uri.
The depth of an hierarchical uri equals the number of slashes
which are not separating the protocol and the host, and not at the end.

@return the depth of this uri if it is hierarchical, or 0 if it is opaque
vespajlib/src/main/java/com/yahoo/net/URI.java