in packages/synthetics-sdk-broken-links/src/link_utils.ts [320:336]
export function sanitizeObjectName(
inputString: string | null | undefined
): string {
if (!inputString || inputString === '.' || inputString === '..') return '_';
// Regular expressions for:
/*eslint no-useless-escape: "off"*/
const invalidCharactersRegex = /[\r\n\u007F-\u009F#\[\]*?:"<>|/]/g; // Control characters, special characters, path separator
const wellKnownPrefixRegex = /^\.well-known\/acme-challenge\//;
// Core sanitization:
return inputString
.replace(wellKnownPrefixRegex, '_') // Replace forbidden prefix
.replace(invalidCharactersRegex, '_') // replace invalid characters
.trim() // Clean up any leading/trailing spaces
.replace(/\s+/g, '_'); // Replace one or more spaces with underscores
}