Browse Source

REPORT-95153 fix: BI.encodeURIComponent 编码异常

es6
zsmj 1 year ago
parent
commit
e17bf87f28
  1. 18
      packages/fineui/src/core/func/alias.js

18
packages/fineui/src/core/func/alias.js

@ -1,9 +1,21 @@
import { each, isFunction, isNull, isObject, isPlainObject, keys, leftPad, parseDateTime, values, isArray } from "../2.base"; import {
each,
get,
isFunction,
isNull,
isObject,
isPlainObject,
keys,
leftPad,
parseDateTime,
values,
isArray
} from "../2.base";
import { replaceAll } from "./string"; import { replaceAll } from "./string";
import { getFullDayName, getMonthName, getTimezone } from "./date"; import { getFullDayName, getMonthName, getTimezone } from "./date";
import { _global } from "../0.foundation"; import { _global } from "../0.foundation";
export const specialCharsMap = {}; const getSpecialCharsMap = () => (get(_global, ["BI", "specialCharsMap"]) || {});
function isEmpty(value) { function isEmpty(value) {
// 判断是否为空值 // 判断是否为空值
@ -624,6 +636,7 @@ export const getEncodeURL = function (urlTemplate, param) {
}; };
export const encodeURIComponent = function(url) { export const encodeURIComponent = function(url) {
const specialCharsMap = getSpecialCharsMap();
url = url || ""; url = url || "";
url = replaceAll(`${url}`, keys(specialCharsMap || []).join("|"), str => { url = replaceAll(`${url}`, keys(specialCharsMap || []).join("|"), str => {
switch (str) { switch (str) {
@ -638,6 +651,7 @@ export const encodeURIComponent = function (url) {
}; };
export const decodeURIComponent = function(url) { export const decodeURIComponent = function(url) {
const specialCharsMap = getSpecialCharsMap();
const reserveSpecialCharsMap = {}; const reserveSpecialCharsMap = {};
each(specialCharsMap, (initialChar, encodeChar) => { each(specialCharsMap, (initialChar, encodeChar) => {
reserveSpecialCharsMap[encodeChar] = initialChar === "\\\\" ? "\\" : initialChar; reserveSpecialCharsMap[encodeChar] = initialChar === "\\\\" ? "\\" : initialChar;

Loading…
Cancel
Save