@ -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 { getFullDayName , getMonthName , getTimezone } from "./date" ;
import { _global } from "../0.foundation" ;
export const specialCharsMap = { } ;
const getSpecialCharsMap = ( ) => ( get ( _global , [ "BI" , "specialCharsMap" ] ) || { } ) ;
function isEmpty ( value ) {
// 判断是否为空值
@ -624,6 +636,7 @@ export const getEncodeURL = function (urlTemplate, param) {
} ;
export const encodeURIComponent = function ( url ) {
const specialCharsMap = getSpecialCharsMap ( ) ;
url = url || "" ;
url = replaceAll ( ` ${ url } ` , keys ( specialCharsMap || [ ] ) . join ( "|" ) , str => {
switch ( str ) {
@ -638,6 +651,7 @@ export const encodeURIComponent = function (url) {
} ;
export const decodeURIComponent = function ( url ) {
const specialCharsMap = getSpecialCharsMap ( ) ;
const reserveSpecialCharsMap = { } ;
each ( specialCharsMap , ( initialChar , encodeChar ) => {
reserveSpecialCharsMap [ encodeChar ] = initialChar === "\\\\" ? "\\" : initialChar ;