@@ -3,29 +3,24 @@ import { connect } from 'react-redux';
3
3
import PropTypes from 'prop-types' ;
4
4
import Popup from '../components/Popup' ;
5
5
import { components } from '../params' ;
6
- import { hostname } from '../localconf' ;
6
+ import { hostnameWithSubdomain } from '../localconf' ;
7
7
import { updateSystemUseNotice } from '../actions' ;
8
8
9
9
const handleAcceptWarning = ( ) => {
10
10
/**
11
11
* If policy is accepted then set systemUseWarnPopup to false, hiding the
12
12
* warning.
13
13
*/
14
- // set a new cookie indicating we have accepted this policy
15
-
16
- const hostnameParts = hostname . split ( '.' ) ;
17
- const hLen = hostnameParts . length ;
18
- const hostnameNoSubdomain = ( hLen > 2 ) ? hostnameParts . splice ( hLen - 2 ) . join ( '.' ) : hostname ;
19
- const domain = hostnameNoSubdomain . endsWith ( '/' ) ? hostnameNoSubdomain . slice ( 0 , - 1 ) : hostnameNoSubdomain ;
20
14
15
+ // set a new cookie indicating we have accepted this policy
21
16
const expiry = new Date ( ) ;
22
17
const defaultDays = 'expireUseMsgDays' in components . systemUse ? components . systemUse . expireUseMsgDays : 0 ;
23
18
24
19
if ( defaultDays === 0 ) { // session cookie
25
- document . cookie = `systemUseWarning=yes; expires=0; path=/; domain=. ${ domain } ` ;
20
+ document . cookie = `systemUseWarning=yes; expires=0; path=/; domain=${ hostnameWithSubdomain } ` ;
26
21
} else {
27
22
expiry . setTime ( expiry . getTime ( ) + ( defaultDays * 1440 * 1 * 60 * 1000 ) ) ; // number of days
28
- document . cookie = `systemUseWarning=yes; expires=${ expiry . toGMTString ( ) } ; path=/; domain=. ${ domain } ` ;
23
+ document . cookie = `systemUseWarning=yes; expires=${ expiry . toGMTString ( ) } ; path=/; domain=${ hostnameWithSubdomain } ` ;
29
24
}
30
25
31
26
return ( dispatch ) => dispatch ( updateSystemUseNotice ( false ) ) ;
0 commit comments