sanitize_identifier

Function sanitize_identifier 

Source
pub fn sanitize_identifier(id: &str) -> String
Expand description

Sanitize an identifier to be a valid TypeScript/JavaScript identifier

Removes or replaces invalid characters:

  • Preserves content inside parentheses and converts to camelCase: “(csv)” -> “Csv”
  • Replaces slashes with “Or”: “/” -> “Or”
  • Removes other invalid characters: spaces, special chars
  • Ensures it starts with a letter or underscore

Examples:

  • “getDownloadExport(csv)” -> “getDownloadExportCsv”
  • “getUser/organizationSettings” -> “getUserOrOrganizationSettings”
  • “postSolveRoutes(aliasOf/routes/plan)” -> “postSolveRoutesAliasOfOrRoutesOrPlan”