byFullUrl method
Enforces that both requests have the same full URL.
If preserveQueryOrder
is true, the order of the query parameters must match as well.
If preserveQueryOrder
is false, the order of the query parameters is ignored.
MatchRules rules = MatchRules().byFullUrl();
Implementation
MatchRules byFullUrl({bool preserveQueryOrder = false}) {
_by((Request received, Request recorded) {
if (preserveQueryOrder) {
return received.uri.toString() == recorded.uri.toString();
} else {
if (received.uri.path != recorded.uri.path) {
return false;
}
Map<String, String> receivedQuery = received.uri.queryParameters;
Map<String, String> recordedQuery = recorded.uri.queryParameters;
if (receivedQuery.length != recordedQuery.length) {
return false;
}
for (String key in receivedQuery.keys) {
if (!recordedQuery.containsKey(key)) {
return false;
}
if (receivedQuery[key] != recordedQuery[key]) {
return false;
}
}
return true;
}
});
return this;
}