mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb: fix get_cookie()
This commit is contained in:
parent
5330859034
commit
7adda3b71a
@ -70,15 +70,14 @@ pub fn (ctx mut Context) set_cookie(key, val string) { // TODO support directive
|
||||
}
|
||||
|
||||
pub fn (ctx &Context) get_cookie(key string) ?string { // TODO refactor
|
||||
cookie_header := ctx.get_header('Cookie')
|
||||
cookie_header := ' ' + ctx.get_header('Cookie')
|
||||
cookie := if cookie_header.contains(';') {
|
||||
cookie_header.find_between('$key=', ';')
|
||||
cookie_header.find_between(' $key=', ';')
|
||||
} else {
|
||||
cookie_header.find_between('$key=', '\r')
|
||||
//cookie_header
|
||||
cookie_header.find_between(' $key=', '\r')
|
||||
}
|
||||
if cookie != '' {
|
||||
return cookie
|
||||
return cookie.trim_space()
|
||||
}
|
||||
return error('Cookie not found')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user