mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
vlib: refactor empty string checks to use s == ''
or s != ''
, instead of s.len == 0
(#21300)
This commit is contained in:
parent
46be635072
commit
8aa9314a99
55 changed files with 95 additions and 96 deletions
|
@ -60,7 +60,7 @@ fn write_page_table(mut sb strings.Builder, uri_path string, requested_file_path
|
|||
sb.writeln('<th align="left" style="width: 200px">Last modified</th>')
|
||||
sb.writeln('<th align="left">Name</th>')
|
||||
sb.writeln('</tr>')
|
||||
if uri_path.len == 0 {
|
||||
if uri_path == '' {
|
||||
sb.writeln('<tr>')
|
||||
sb.writeln('<td>---</td>')
|
||||
sb.writeln('<td>---</td>')
|
||||
|
|
|
@ -17,7 +17,7 @@ fn test_http_get_from_vlang_utc_now() {
|
|||
println('Test getting current time from ${url} by http.get')
|
||||
res := http.get(url) or { panic(err) }
|
||||
assert res.status() == .ok
|
||||
assert res.body.len > 0
|
||||
assert res.body != ''
|
||||
assert res.body.int() > 1566403696
|
||||
println('Current time is: ${res.body.int()}')
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ fn test_public_servers() {
|
|||
println('Testing http.get on public url: ${url} ')
|
||||
res := http.get(url) or { panic(err) }
|
||||
assert res.status() == .ok
|
||||
assert res.body.len > 0
|
||||
assert res.body != ''
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,6 @@ fn test_relative_redirects() {
|
|||
} // tempfix periodic: httpbin relative redirects are broken
|
||||
res := http.get('https://httpbin.org/relative-redirect/3?abc=xyz') or { panic(err) }
|
||||
assert res.status() == .ok
|
||||
assert res.body.len > 0
|
||||
assert res.body != ''
|
||||
assert res.body.contains('"abc": "xyz"')
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ pub fn new_response(conf ResponseConfig) Response {
|
|||
body: conf.body
|
||||
header: conf.header
|
||||
}
|
||||
if resp.body.len > 0 && !resp.header.contains(.content_length) {
|
||||
if resp.body != '' && !resp.header.contains(.content_length) {
|
||||
resp.header.add(.content_length, resp.body.len.str())
|
||||
}
|
||||
resp.set_status(conf.status)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue