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 {
|
||||
return value
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'");
|
||||
return value.replace(/&(amp|lt|gt|quot|#39);/g, (_match, entity) => {
|
||||
switch (entity) {
|
||||
case 'amp':
|
||||
return '&';
|
||||
case 'lt':
|
||||
return '<';
|
||||
case 'gt':
|
||||
return '>';
|
||||
case 'quot':
|
||||
return '"';
|
||||
case '#39':
|
||||
return "'";
|
||||
default:
|
||||
return _match;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function parseHttpDate(value: string): string | null {
|
||||
|
||||
Reference in New Issue
Block a user