From 6929ab47f9d4b2290617ddd39cd4a7d17be2ee34 Mon Sep 17 00:00:00 2001 From: Dag Date: Wed, 29 Jun 2022 23:21:24 +0200 Subject: [PATCH] fix: cookie bug --- src/http/Cookie.php | 2 +- tests/http.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/http.php diff --git a/src/http/Cookie.php b/src/http/Cookie.php index 30f4e45..7c0ebe9 100755 --- a/src/http/Cookie.php +++ b/src/http/Cookie.php @@ -10,6 +10,7 @@ final class Cookie public static function fromString(string $cookieString): self { + $cookieString = ltrim($cookieString, '; '); $parts = explode(';', $cookieString); $nameAndValue = explode('=', $parts[0]); @@ -25,7 +26,6 @@ final class Cookie public function send(): void { $options = [ - ]; setcookie($this->name, $this->value, $options); } diff --git a/tests/http.php b/tests/http.php new file mode 100644 index 0000000..0ceb904 --- /dev/null +++ b/tests/http.php @@ -0,0 +1,10 @@ +name, $sut->value]); + +$sut = Cookie::fromString('; foo=bar'); +assertEquals(['foo', 'bar'], [$sut->name, $sut->value]); \ No newline at end of file -- 2.45.2