From 0d3e799633d5d929c86919d26374cc55e7ffd828 Mon Sep 17 00:00:00 2001 From: Abderrahim Dahmani <80603216+AbdrrahimDahmani@users.noreply.github.com> Date: Thu, 24 Aug 2023 12:23:44 +0100 Subject: [PATCH] added auto value casting from integer to string --- projects/ngx-cookie-service/src/lib/cookie.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/ngx-cookie-service/src/lib/cookie.service.ts b/projects/ngx-cookie-service/src/lib/cookie.service.ts index 7cd5157..3e918f1 100644 --- a/projects/ngx-cookie-service/src/lib/cookie.service.ts +++ b/projects/ngx-cookie-service/src/lib/cookie.service.ts @@ -176,7 +176,7 @@ export class CookieService { set( name: string, - value: string, + value: string | number, expiresOrOptions?: CookieOptions['expires'] | CookieOptions, path?: CookieOptions['path'], domain?: CookieOptions['domain'], @@ -186,7 +186,9 @@ export class CookieService { if (!this.documentIsAccessible) { return; } - + if (typeof value === 'number') { + value = value.toString(); + } if (typeof expiresOrOptions === 'number' || expiresOrOptions instanceof Date || path || domain || secure || sameSite) { const optionsBody = { expires: expiresOrOptions as CookieOptions['expires'],