File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -74,9 +74,15 @@ export function startObservingColorSchemeHtmlAttribute() {
7474 const setColorSchemeCookie = ( colorScheme : ColorScheme ) => {
7575 let newCookie = `${ data_fr_theme } =${ colorScheme } ;path=/;max-age=31536000` ;
7676
77- //We do not set the domain if we are on localhost or an ip
78- if ( window . location . hostname . match ( / \. [ a - z A - Z ] { 2 , } $ / ) ) {
79- newCookie += `;domain=${ window . location . hostname } ` ;
77+ set_domain: {
78+ const { hostname } = window . location ;
79+
80+ //We do not set the domain if we are on localhost or an ip
81+ if ( / ( ^ l o c a l h o s t $ ) | ( ^ ( ( 2 5 [ 0 - 5 ] | ( 2 [ 0 - 4 ] | 1 \d | [ 1 - 9 ] | ) \d ) \. ? \b ) { 4 } $ ) / . test ( hostname ) ) {
82+ break set_domain;
83+ }
84+
85+ newCookie += `;domain=${ hostname } ` ;
8086 }
8187
8288 document . cookie = newCookie ;
You can’t perform that action at this time.
0 commit comments