+
+ // Split at the first slash, or the first colon that's not within [].
+ bool within_brackets = false;
+ for (split = 0; split < rest.size(); ++split) {
+ if (rest[split] == '[') {
+ if (within_brackets) {
+ // Can't nest brackets.
+ return false;
+ }
+ within_brackets = true;
+ } else if (rest[split] == ']') {
+ if (!within_brackets) {
+ // ] without matching [.
+ return false;
+ }
+ within_brackets = false;
+ } else if (rest[split] == '/') {
+ break;
+ } else if (rest[split] == ':' && !within_brackets) {
+ break;
+ }
+ }
+
+ if (split == rest.size()) {