@@ -12,6 +12,19 @@ const ALLOWED_STATUSES = [200, 201];
1212const REQUEST_TIMEOUT = 1800000 ;
1313const MIN_VIEWPORT_HEIGHT = 1080 ;
1414
15+ const normalizeSameSite = ( value ) => {
16+ if ( ! value ) return 'Lax' ;
17+
18+ const normalized = value . trim ( ) . toLowerCase ( ) ;
19+ const mapping = {
20+ 'lax' : 'Lax' ,
21+ 'strict' : 'Strict' ,
22+ 'none' : 'None'
23+ } ;
24+
25+ return mapping [ normalized ] || value ;
26+ } ;
27+
1528export async function prepareSnapshot ( snapshot : Snapshot , ctx : Context ) : Promise < Record < string , any > > {
1629 let processedOptions : Record < string , any > = { } ;
1730 processedOptions . cliEnableJavascript = ctx . config . cliEnableJavaScript ;
@@ -257,11 +270,11 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
257270 return false ;
258271 }
259272
260- if ( cookie . sameSite && ! [ 'Strict' , 'Lax' , 'None' ] . includes ( cookie . sameSite ) ) {
273+ const sameSiteValue = normalizeSameSite ( cookie . sameSite ) ;
274+ if ( ! [ 'Strict' , 'Lax' , 'None' ] . includes ( sameSiteValue ) ) {
261275 ctx . log . debug ( `Skipping invalid custom cookie: invalid sameSite value '${ cookie . sameSite } '` ) ;
262276 return false ;
263277 }
264-
265278 return true ;
266279 } ) . map ( cookie => ( {
267280 name : cookie . name ,
@@ -270,7 +283,7 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
270283 path : cookie . path || '/' ,
271284 httpOnly : cookie . httpOnly || false ,
272285 secure : cookie . secure || false ,
273- sameSite : cookie . sameSite || 'Lax'
286+ sameSite : normalizeSameSite ( cookie . sameSite )
274287 } ) ) ;
275288
276289 if ( validCustomCookies . length > 0 ) {
0 commit comments