From 42b041773294abb832bd3edad517eda4db524cbd Mon Sep 17 00:00:00 2001 From: Mehdi Mehdizadeh Date: Thu, 24 Oct 2024 09:36:26 +0330 Subject: [PATCH] Fix: error when user agent is null --- src/Drivers/JenssegersAgent.php | 2 +- src/Drivers/UAParser.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Drivers/JenssegersAgent.php b/src/Drivers/JenssegersAgent.php index 415f778..4d2f325 100755 --- a/src/Drivers/JenssegersAgent.php +++ b/src/Drivers/JenssegersAgent.php @@ -68,7 +68,7 @@ protected function initParser(): Agent { $parser = new Agent(); - $parser->setUserAgent($this->request->userAgent()); + $parser->setUserAgent($this->request->userAgent() ?? "N/A"); $parser->setHttpHeaders((array)$this->request->headers); return $parser; diff --git a/src/Drivers/UAParser.php b/src/Drivers/UAParser.php index 1ca62ab..70f0c88 100755 --- a/src/Drivers/UAParser.php +++ b/src/Drivers/UAParser.php @@ -77,6 +77,6 @@ public function languages() : array */ protected function initParser(): \UAParser\Result\Client { - return Parser::create()->parse($this->request->userAgent()); + return Parser::create()->parse($this->request->userAgent() ?? "N/A"); } }