// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /** * Escapes special XML characters in a string * @param str - String to escape * @returns XML-escaped string */ const escapeXml = (str: string): string => { return str .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); }; /** * Generates XML for S3 batch delete operations * * @param objects - Array of objects to delete with their keys * @param quiet - Whether to use quiet mode (default: true) * @returns XML string for the delete request */ export const generateDeleteObjectsXml = ( objects: { Key: string }[], quiet: boolean, ): string => { const objectsXml = objects .map(obj => `${escapeXml(obj.Key)}`) .join(''); return ` ${quiet ? 'true' : 'false'} ${objectsXml} `; };