1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

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 {