Skip to content

Commit 3bb48c9

Browse files
committed
优化路径处理,避免非index.html的路径被加上/,导致umami查询参数错误
1 parent ba7d678 commit 3bb48c9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/js/umami-view.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ let viewCtn = document.querySelector("#umami-page-views-container");
9494
// 如果页面容器存在,则获取页面浏览量
9595
if (viewCtn) {
9696
let path = window.location.pathname;
97-
let target = decodeURI(path.replace(/\/*(index.html)?$/, "/"));
97+
let target = path
98+
.replace(/(\/[^/]+\.html)\/$/, "$1") // 如果是 /xxx.html/ 则去掉最后那个 /
99+
.replace(/\/index\.html$/, "/"); // 如果是 /index.html 则归一成 /
98100
pageStats(target);
99101
}

0 commit comments

Comments
 (0)