Files
MyAiConfiguration/scripts/benchmarks/tasks/05-write-tests/repo/app/slug.py
T
Julian lechnerandClaude Opus 5.5 3480072ed7 test(benchmarks): add A/B task fixtures with hidden checks
Ten small Python tasks, each failing on the fixture and passing with a
reference solution, including workflow expectations for a small change, a
bugfix, and a delegable change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 12:45:40 +02:00

10 lines
355 B
Python

import re
import unicodedata
def slugify(text, max_length=50):
"""Lowercase ASCII slug with single hyphens, trimmed to max_length without a trailing hyphen."""
text = unicodedata.normalize("NFKD", text).encode("ascii", "ignore").decode()
text = re.sub(r"[^a-zA-Z0-9]+", "-", text).strip("-").lower()
return text[:max_length].rstrip("-")