Browse Source

decodeURIComponentSafe使用utils中的方法

lifanagju_citu 1 month ago
parent
commit
9c67d2f3b1
1 changed files with 1 additions and 10 deletions
  1. 1 10
      utils/openEncryption.js

+ 1 - 10
utils/openEncryption.js

@@ -12,6 +12,7 @@
 
 
 import { generateUUID } from "@/utils/index" 
 import { generateUUID } from "@/utils/index" 
 import { sha256 } from 'js-sha256'
 import { sha256 } from 'js-sha256'
+import { decodeURIComponentSafe } from '@/utils/index'
 
 
 /**
 /**
  * 
  * 
@@ -20,16 +21,6 @@ import { sha256 } from 'js-sha256'
  * @returns 
  * @returns 
 */
 */
 
 
-// 替换无效编码序列(解决 decodeURIComponent 报错 "URI malformed" 的问题)
-export const decodeURIComponentSafe = (str) => {
-  try {
-    return decodeURIComponent(str);
-  } catch (e) {
-    // 替换无效的百分号编码为空字符串
-    return decodeURIComponent(str.replace(/%(?![\da-f]{2})/gi, ''));
-  }
-}
-
 export const encryptionFun = ({raw, body, appId, AppSecret, timestamp}) => {
 export const encryptionFun = ({raw, body, appId, AppSecret, timestamp}) => {
   const initSign = {
   const initSign = {
     appId,
     appId,