浏览代码

feat: 在_base64Decode函数中添加URL解码支持

kibble5788 3 月之前
父节点
当前提交
9c781cd059
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      apps/en-decode/endecode-lib.js

+ 9 - 0
apps/en-decode/endecode-lib.js

@@ -172,6 +172,15 @@ let EncodeUtils = (() => {
      * @return {String} 源码
      */
     let _base64Decode = function (str) {
+          // 检测是否包含URL编码的字符,如果有则先进行URL解码
+        if (str.includes("%")) {
+          try {
+            str = decodeURIComponent(str);
+          } catch (e) {
+            // 如果URL解码失败,继续使用原字符串
+            console.warn("URL解码失败,使用原字符串:", e.message);
+          }
+        }
         let c1, c2, c3, c4;
         let i, len, out;
         len = str.length;