@@ -85,29 +85,31 @@ class ZitiClient {
8585 let name = cookie . substring ( 0 , cookie . indexOf ( "=" ) ) ;
8686 let value = cookie . substring ( cookie . indexOf ( "=" ) + 1 ) ;
8787 let cookie_value = value . substring ( 0 , value . indexOf ( ";" ) ) ;
88- let parts = value . split ( ";" ) ;
89- let cookiePath ;
90- let expires ;
91- for ( let j = 0 ; j < parts . length ; j ++ ) {
92- let part = parts [ j ] . trim ( ) ;
93- part = part . toLowerCase ( ) ;
94- if ( part . startsWith ( "path" ) ) {
95- cookiePath = part . substring ( part . indexOf ( "=" ) + 1 ) ;
96- }
97- else if ( part . startsWith ( "expires" ) ) {
98- expires = new Date ( part . substring ( part . indexOf ( "=" ) + 1 ) ) ;
99- }
100- else if ( part . startsWith ( "httponly" ) ) {
101- httpOnly = true ;
88+ if ( cookie_value !== '' ) {
89+ let parts = value . split ( ";" ) ;
90+ let cookiePath ;
91+ let expires ;
92+ for ( let j = 0 ; j < parts . length ; j ++ ) {
93+ let part = parts [ j ] . trim ( ) ;
94+ part = part . toLowerCase ( ) ;
95+ if ( part . startsWith ( "path" ) ) {
96+ cookiePath = part . substring ( part . indexOf ( "=" ) + 1 ) ;
97+ }
98+ else if ( part . startsWith ( "expires" ) ) {
99+ expires = new Date ( part . substring ( part . indexOf ( "=" ) + 1 ) ) ;
100+ }
101+ else if ( part . startsWith ( "httponly" ) ) {
102+ httpOnly = true ;
103+ }
102104 }
105+
106+ zitiCookies [ name ] = cookie_value ;
107+
108+ // console.log('=====> CookieInterceptor ZITI_COOKIES (after): ', zitiCookies);
109+
110+ await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_COOKIES , zitiCookies , new Date ( 8640000000000000 ) ) ;
103111 }
104112
105- zitiCookies [ name ] = cookie_value ;
106-
107- // console.log('=====> CookieInterceptor ZITI_COOKIES (after): ', zitiCookies);
108-
109- await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_COOKIES , zitiCookies , new Date ( 8640000000000000 ) ) ;
110-
111113 release ( ) ;
112114
113115 } ) ( )
@@ -462,24 +464,27 @@ class ZitiClient {
462464 let name = cookie . substring ( 0 , cookie . indexOf ( "=" ) ) ;
463465 let value = cookie . substring ( cookie . indexOf ( "=" ) + 1 ) ;
464466 let cookie_value = value . substring ( 0 , value . indexOf ( ";" ) ) ;
465- let parts = value . split ( ";" ) ;
466- for ( let j = 0 ; j < parts . length ; j ++ ) {
467- let part = parts [ j ] . trim ( ) ;
468- if ( part . startsWith ( "Path" ) ) {
469- cookiePath = part . substring ( part . indexOf ( "=" ) + 1 ) ;
470- }
471- else if ( part . startsWith ( "Expires" ) ) {
472- expires = new Date ( part . substring ( part . indexOf ( "=" ) + 1 ) ) ;
473- }
474- else if ( part . startsWith ( "HttpOnly" ) ) {
475- httpOnly = true ;
467+ if ( cookie_value !== '' ) {
468+ let parts = value . split ( ";" ) ;
469+ for ( let j = 0 ; j < parts . length ; j ++ ) {
470+ let part = parts [ j ] . trim ( ) ;
471+ if ( part . startsWith ( "Path" ) ) {
472+ cookiePath = part . substring ( part . indexOf ( "=" ) + 1 ) ;
473+ }
474+ else if ( part . startsWith ( "Expires" ) ) {
475+ expires = new Date ( part . substring ( part . indexOf ( "=" ) + 1 ) ) ;
476+ }
477+ else if ( part . startsWith ( "HttpOnly" ) ) {
478+ httpOnly = true ;
479+ }
476480 }
481+
482+ zitiCookies [ name ] = cookie_value ;
483+
484+ await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_COOKIES , zitiCookies , new Date ( 8640000000000000 ) ) ;
485+
486+ Cookies . set ( name , cookie_value , { expires : expires , path : cookiePath } ) ;
477487 }
478-
479-
480- zitiCookies [ name ] = cookie_value ;
481-
482- await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_COOKIES , zitiCookies , new Date ( 8640000000000000 ) ) ;
483488 }
484489 }
485490 }
@@ -633,8 +638,7 @@ zitiFetch = async ( url, opts ) => {
633638 } else { // the request is targeting the raw internet
634639
635640 ziti . _ctx . logger . warn ( 'zitiFetch(): no associated serviceConfig, bypassing intercept of [%s]' , url ) ;
636- var resp = window . realFetch ( url , opts ) ;
637- return resp ;
641+ return window . realFetch ( url , opts ) ;
638642 }
639643
640644 /**
@@ -734,24 +738,28 @@ zitiFetch = async ( url, opts ) => {
734738 let name = cookie . substring ( 0 , cookie . indexOf ( "=" ) ) ;
735739 let value = cookie . substring ( cookie . indexOf ( "=" ) + 1 ) ;
736740 let cookie_value = value . substring ( 0 , value . indexOf ( ";" ) ) ;
737- let parts = value . split ( ";" ) ;
738- for ( let j = 0 ; j < parts . length ; j ++ ) {
739- let part = parts [ j ] . trim ( ) ;
740- if ( part . startsWith ( "Path" ) ) {
741- cookiePath = part . substring ( part . indexOf ( "=" ) + 1 ) ;
742- }
743- else if ( part . startsWith ( "Expires" ) ) {
744- expires = new Date ( part . substring ( part . indexOf ( "=" ) + 1 ) ) ;
745- }
746- else if ( part . startsWith ( "HttpOnly" ) ) {
747- httpOnly = true ;
741+ if ( cookie_value !== '' ) {
742+ let parts = value . split ( ";" ) ;
743+ for ( let j = 0 ; j < parts . length ; j ++ ) {
744+ let part = parts [ j ] . trim ( ) ;
745+ if ( part . startsWith ( "Path" ) ) {
746+ cookiePath = part . substring ( part . indexOf ( "=" ) + 1 ) ;
747+ }
748+ else if ( part . startsWith ( "Expires" ) ) {
749+ expires = new Date ( part . substring ( part . indexOf ( "=" ) + 1 ) ) ;
750+ }
751+ else if ( part . startsWith ( "HttpOnly" ) ) {
752+ httpOnly = true ;
753+ }
748754 }
749- }
750755
751756
752- zitiCookies [ name ] = cookie_value ;
757+ zitiCookies [ name ] = cookie_value ;
758+
759+ await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_COOKIES , zitiCookies , new Date ( 8640000000000000 ) ) ;
753760
754- await ls . setWithExpiry ( zitiConstants . get ( ) . ZITI_COOKIES , zitiCookies , new Date ( 8640000000000000 ) ) ;
761+ Cookies . set ( name , cookie_value , { expires : expires , path : cookiePath } ) ;
762+ }
755763 }
756764 }
757765 }
0 commit comments