owner method
The host that owns internalPath: the entry with the longest mount
containing it, the primary host when none does.
Implementation
DVHostMatch owner(String internalPath) {
final List<String> path = _segments(internalPath);
DVHostMatch? best;
int bestLength = -1;
bool bestLiteral = false;
for (final DVHostEntry e in entries) {
if (e.isPrimary) continue;
final List<String> mount = _segments(e.mount);
if (mount.length > path.length) continue;
String? label;
bool fits = true;
for (int i = 0; i < mount.length; i++) {
if (mount[i] == '{label}') {
if (!_isLabel(path[i])) {
fits = false;
break;
}
label = path[i];
} else if (mount[i] != path[i]) {
fits = false;
break;
}
}
if (!fits) continue;
final bool literal = label == null;
if (mount.length > bestLength ||
(mount.length == bestLength && literal && !bestLiteral)) {
best = DVHostMatch(e, label: label);
bestLength = mount.length;
bestLiteral = literal;
}
}
return best ?? primaryMatch;
}