From 28b4b0885b8caefdc33cef3decd4118cd0831d6c Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Sat, 9 Mar 2024 00:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0index.html=E4=B8=AD=E7=BC=BA?= =?UTF-8?q?=E5=B0=91=E7=9A=84extractLocation=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/index.html b/index.html index 22e37375f..26ccba872 100755 --- a/index.html +++ b/index.html @@ -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);