Need help “sanitizing” a custom function that pulls category slug into body class

Just use $category->slug instead of $category->cat_name. Slugs are already lowercase and with dashes instead of spaces.