Download bugfix_case_study/bugfix.diff from protoneko/freelance-samples: direct link, hf CLI and curl.
- Browser
- Download file 990 Bytes
-
https://huggingface.co/datasets/protoneko/freelance-samples/resolve/main/bugfix_case_study/bugfix.diff
- Command line
-
hf download hf://datasets/protoneko/freelance-samples/bugfix_case_study/bugfix.diff
-
curl -L -o bugfix.diff https://huggingface.co/datasets/protoneko/freelance-samples/resolve/main/bugfix_case_study/bugfix.diff
990 Bytes
| diff --git a/slugify/slugify.py b/slugify/slugify.py | |
| index 0194378..ebe424a 100644 | |
| --- a/slugify/slugify.py | |
| +++ b/slugify/slugify.py | |
| def _modern_truncate(text: str, max_length: int, word_boundary: bool, separator: | |
| # A hard cut may shorten a word but must not emit a partial/trailing delimiter. | |
| parts: list[str] = [] | |
| length = 0 | |
| + previous_index = 0 | |
| for index, word in enumerate(tokens): | |
| - delimiter = separator if index else '' | |
| + if not word: | |
| + continue | |
| + # Keep repeated delimiters with the next nonempty word until it fits. | |
| + delimiter = separator * (index - previous_index) | |
| remaining = max_length - length - len(delimiter) | |
| if remaining <= 0: | |
| break | |
| parts.append(delimiter + word[:remaining]) | |
| length += len(delimiter) + min(len(word), remaining) | |
| + previous_index = index | |
| if len(word) > remaining: | |
| break | |
| return ''.join(parts) | |