mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 21:00:41 +00:00
feat: optimize XML decoding by using a switch statement for entity replacements
This commit is contained in:
@@ -89,12 +89,22 @@ function sortRemoteItems(items: RemoteBackupItem[]): RemoteBackupItem[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function decodeXmlText(value: string): string {
|
function decodeXmlText(value: string): string {
|
||||||
return value
|
return value.replace(/&(amp|lt|gt|quot|#39);/g, (_match, entity) => {
|
||||||
.replace(/&/g, '&')
|
switch (entity) {
|
||||||
.replace(/</g, '<')
|
case 'amp':
|
||||||
.replace(/>/g, '>')
|
return '&';
|
||||||
.replace(/"/g, '"')
|
case 'lt':
|
||||||
.replace(/'/g, "'");
|
return '<';
|
||||||
|
case 'gt':
|
||||||
|
return '>';
|
||||||
|
case 'quot':
|
||||||
|
return '"';
|
||||||
|
case '#39':
|
||||||
|
return "'";
|
||||||
|
default:
|
||||||
|
return _match;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseHttpDate(value: string): string | null {
|
function parseHttpDate(value: string): string | null {
|
||||||
|
|||||||
Reference in New Issue
Block a user