hashParam 同时读 hash+query: 修复浏览器直访(?openid=)读不到身份导致整页停在演示默认值 (v26090712)
This commit is contained in:
@@ -4035,11 +4035,14 @@
|
||||
打回白板。同样静默失败,不打断用户。
|
||||
⚠️ 竞态:fetch 异步,回来时 init() 已跑完,这里只需回刷那些读 state 的展示。 */
|
||||
function hashParam(name) {
|
||||
/* 同时读 hash 和 query:浏览器直访(?openid=x)只有 query;
|
||||
小程序 web-view 的授权回传在 hash(微信 webview 丢 query 不丢 hash)。
|
||||
⚠️ 先在原始串上匹配、再对捕获值 decode —— 先 decode 整串会把
|
||||
%26 之类的编码提前还原成 &,破坏参数切分。 */
|
||||
try {
|
||||
const h = decodeURIComponent(location.hash.slice(1));
|
||||
/* openid 是首个参数时前面没有 &/#(如 "#openid=x"),[&#] 是"或",作可省处理 */
|
||||
const h = (location.hash.slice(1) || '') + '&' + (location.search.slice(1) || '');
|
||||
const m = h.match(new RegExp('(?:^|[&#])' + name + '=([^&#]*)'));
|
||||
return m ? m[1] : '';
|
||||
return m ? decodeURIComponent(m[1]) : '';
|
||||
} catch (e) { return ''; }
|
||||
}
|
||||
let _profileApplied = false;
|
||||
|
||||
Reference in New Issue
Block a user