增加&#xxxx;的支持
This commit is contained in:
@ -26,9 +26,9 @@ export function escape(str: string) {
|
||||
* @returns
|
||||
*/
|
||||
export function unescape(str: string) {
|
||||
return str.replace(/&(\w+);/g, (match, name, index) => {
|
||||
const code = unescapeTable[name]
|
||||
if (!code) return match
|
||||
return str.replace(/&((\w+)|(#\d+));/g, (match, name) => {
|
||||
const code = (name[0] == '#') ? parseInt(name.substr(1)) : unescapeTable[name]
|
||||
if (!code || isNaN(code)) return match
|
||||
return String.fromCharCode(code)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user