Fix doChangeLangType() redirecting to main page when short URL is used

https://xetown.com/questions/1381097
This commit is contained in:
Kijin Sung 2020-04-18 10:23:54 +09:00
parent 4bac63f387
commit e33d8569bc

View file

@ -486,7 +486,7 @@ jQuery(function($) {
var filename = uri.filename() || 'index.php';
var queries = uri.search(true);
if(window.XE.isSameHost(uri.toString()) && $.isEmptyObject(queries)) {
if(window.XE.isSameHost(uri.toString()) && filename === 'index.php' && $.isEmptyObject(queries)) {
filename = '';
}
@ -721,7 +721,11 @@ function doChangeLangType(obj) {
var val = obj.options[obj.selectedIndex].value;
setLangType(val);
}
location.href = location.href.setQuery('l', '');
if(location.href.match(/[?&]l=[a-z]+/)) {
location.href = location.href.setQuery('l', '');
} else {
location.reload();
}
}
function setLangType(lang_type) {
XE.cookie.set("lang_type", lang_type, { path: "/", expires: 3650 });