添加index.html中缺少的extractLocation函数

This commit is contained in:
nonameShijian 2024-03-09 00:38:21 +08:00
parent 7001d91654
commit 28b4b0885b
1 changed files with 13 additions and 0 deletions

View File

@ -19,6 +19,19 @@
};
const STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
const errorList = [];
function extractLocation(urlLike) {
// 不存在地址信息的字符串
if (!/:/.test(urlLike)) {
return [urlLike];
}
// 捕获位置用到的正则
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
const parts = regExp.exec(urlLike.replace(/[()]/g, ''));
// @ts-ignore
return [parts[1], parts[2] || void 0, parts[3] || void 0];
}
window.onunhandledrejection = async event => {
event.promise.catch(error => {
console.log(error);