net.http: use .filter in sanitize/2 (#8899)

pull/8904/head
Swastik Baranwal 2021-02-22 18:28:48 +05:30 committed by GitHub
parent 1658c4789f
commit b2cdd2cac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 9 deletions

View File

@ -277,15 +277,7 @@ fn sanitize(valid fn(byte) bool, v string) string {
if ok {
return v.clone()
}
// TODO: Use `filter` instead of this nonesense
buf := v.bytes()
mut bytes := v.bytes()
for i, _ in buf {
if !valid(buf[i]) {
bytes.delete(i)
}
}
return bytes.bytestr()
return v.bytes().filter(valid(it)).bytestr()
}
fn sanitize_cookie_name(name string) string {