Repository navigation
Drop a trailing period from a suggested file name [patch] - #205
Conversation
Models often end the answer with a full stop. SanitizeFileName kept it, so "sunset-over-the-lake." became "sunset-over-the-lake..jpg", "photo.jpg." kept its extension, and "..." became "....jpg" instead of "unnamed.jpg". Trim trailing periods before the extension check, and include the period in the final trim so a name left as only dots falls back to "unnamed". Fixes #196 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01URmxVUpdaWCEUSPudDfLsq
Path.GetExtension("sunset.?") is ".?" on Windows, which FileExtension
refuses, so the case threw before reaching the trim it was meant to test.
"sunset.-" exercises the same trailing-period trim on every platform.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01URmxVUpdaWCEUSPudDfLsq
|
The first push failed Not fixed here, because it is outside this PR's scope: the same crash exists on Generated by Claude Code |
|



Fixes #196
What was wrong
Models often end their answer with a full stop, even when asked for just a file name.
Scan.SanitizeFileNamekept that period at every step.Path.GetExtension("sunset.")is empty,.is a legal character, and the final trim removed only-and space. So:sunset-over-the-lake.sunset-over-the-lake..jpgsunset-over-the-lake.jpgphoto.jpg.(to.png)photo.jpg..pngphoto.png.......jpgunnamed.jpgA suggestion is stored once per hash and never regenerated, so the bad name stayed in the database for good.
Change
photo.jpg.lose its image extension..to the final trim set. A name made only of dots now falls back tounnamed. So does a period left at the end once the final trim removes a trailing hyphen (sunset.-givessunset.jpg).st.-louis-arch-at-duskandsunset-at-5.30pmtests still pass.Tests
New
ScanTestscases:SanitizeFileNameDropsTrailingPeriod(4 rows),SanitizeFileNameStripsImageExtensionFollowedByPeriod,SanitizeFileNameReturnsUnnamedForOnlyPeriods(3 rows), andSanitizeFileNameDropsPeriodLeftBeforeTrimmedHyphen.ScanForImagesSkipsUnreadableSubdirectories, which is inconclusive when run as root.Not covered: names already stored with
..are not rewritten. The triage note suggests a one-off cleanup or a re-suggest path for those, which is a separate change. I've also left alone a Windows-only crash that already exists onmain: an extension that Windows rejects, such as.?, throws insideIsImageExtension. It is described in the comment below.🤖 Generated with Claude Code
https://claude.ai/code/session_01URmxVUpdaWCEUSPudDfLsq