From 7adda3b71a4eef510d3ff21272dee62f16bd20f2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 8 Dec 2019 01:48:49 +0300 Subject: [PATCH] vweb: fix get_cookie() --- vlib/vweb/vweb.v | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index fd15ce5993..1c9e4f0785 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -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') }