From e33d8569bc673f993374141a3348aae86a2f5f84 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 18 Apr 2020 10:23:54 +0900 Subject: [PATCH] Fix doChangeLangType() redirecting to main page when short URL is used https://xetown.com/questions/1381097 --- common/js/common.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/js/common.js b/common/js/common.js index a676b1cb8..aa9f90a9c 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -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 });