Add test coverage to ensure filters don't unexpectedly get broken

This commit is contained in:
Dane Everitt 2020-10-15 21:52:26 -07:00
parent 40d44598da
commit cd3572730b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 102 additions and 2 deletions

View file

@ -48,12 +48,12 @@ class MultiFieldServerFilter implements Filter
function (Builder $builder) use ($parts) {
$builder->orWhere('allocations.ip', $parts[0]);
if (!is_null($parts[1] ?? null)) {
$builder->where('allocations.port', 'LIKE', "%{$parts[1]}");
$builder->where('allocations.port', 'LIKE', "{$parts[1]}%");
}
},
// Otherwise, just try to search for that specific port in the allocations.
function (Builder $builder) use ($value) {
$builder->orWhere('allocations.port', substr($value, 1));
$builder->orWhere('allocations.port', 'LIKE', substr($value, 1) . '%');
}
);
})