mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
Merge pull request #3663 from chrisgarrity/language-cookie-fix2
Ensure that the old scratchlanguage cookie is removed if it exists.
This commit is contained in:
commit
643d055001
2 changed files with 16 additions and 1 deletions
11
src/init.js
11
src/init.js
|
@ -18,6 +18,17 @@ const jar = require('./lib/jar');
|
||||||
if (['pt', 'pt-pt', 'PT', 'PT-PT'].indexOf(obj) !== -1) {
|
if (['pt', 'pt-pt', 'PT', 'PT-PT'].indexOf(obj) !== -1) {
|
||||||
obj = 'pt-br'; // default Portuguese users to Brazilian Portuguese due to our user base. Added in 2.2.5.
|
obj = 'pt-br'; // default Portuguese users to Brazilian Portuguese due to our user base. Added in 2.2.5.
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// delete the old cookie (just hostname) by setting it to null and expiring in the past
|
||||||
|
/* eslint-disable max-len */
|
||||||
|
document.cookie = `scratchlanguage=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${window.location.hostname}`;
|
||||||
|
/* eslint-enable max-len */
|
||||||
|
// create the new cookie
|
||||||
|
let opts = {};
|
||||||
|
if (window.location.hostname !== 'localhost') {
|
||||||
|
opts = {domain: `.${window.location.hostname}`};
|
||||||
|
}
|
||||||
|
jar.set('scratchlanguage', obj, opts);
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
|
@ -626,7 +626,11 @@ class Preview extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
handleSetLanguage (locale) {
|
handleSetLanguage (locale) {
|
||||||
jar.set('scratchlanguage', locale);
|
let opts = {};
|
||||||
|
if (window.location.hostname !== 'localhost') {
|
||||||
|
opts = {domain: `.${window.location.hostname}`};
|
||||||
|
}
|
||||||
|
jar.set('scratchlanguage', locale, opts);
|
||||||
}
|
}
|
||||||
handleUpdateProjectId (projectId, callback) {
|
handleUpdateProjectId (projectId, callback) {
|
||||||
this.setState({projectId: projectId}, () => {
|
this.setState({projectId: projectId}, () => {
|
||||||
|
|
Loading…
Reference in a new issue