Keep fenced and dotted filename suggestions intact [patch] - #169
Merged
Merged
Conversation
SanitizeFileName trimmed backticks before taking the first line, so a name inside a code fence left an empty first line and became "unnamed". It also treated any dot as an extension, so "sunset-at-5.30pm" became "sunset-at-5". Take the first line that has content and isn't a fence, then trim, and strip only a known image extension, reusing ImageScanner's set. Fixes #166 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QtRTdtw1SbV7ugjz5wPFgc
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #166
What changed
Scan.SanitizeFileNamehad two bugs:```\nsunset-over-lake\n```) was left with an empty first line and becameunnamed.jpg. It now takes the first line that has content and isn't a fence (```or```text), and trims quotes and backticks after that. A name written inline between fences on one line (```sunset```) is still read.st.-louis-arch-at-duskbecamest.jpgandsunset-at-5.30pmbecamesunset-at-5.jpg. It now strips only a known image extension (case-insensitive). The check uses a newImageScanner.IsImageExtension, whichScanForImagesalso calls now, so there is one extension list.Tests
Added beside the existing
SanitizeFileName*tests inScanTests.cs:```\nsunset-over-lake\n```sunset-over-lake.jpgunnamed.jpg)```text\r\nsunset-over-lake\r\n```sunset-over-lake.jpgst.-louis-arch-at-duskst.-louis-arch-at-dusk.jpgst.jpg)sunset-at-5.30pmsunset-at-5.30pm.jpg\nsunset-over-lake\nsunset-over-lake.jpg```sunset-over-lake```sunset-over-lake.jpgphoto.JPEG→.pngphoto.pngNote: the issue lists
"\nsunset-over-lake\n"as broken, but the old code's leadingTrim()already removed those newlines, so that case worked. The test is kept as a regression guard.Full suite: 53 passed. With
Scan.csreverted, the four tests marked "fails" above fail.The triage comment suggests a follow-up for names already stored as
unnamed.*. That is out of scope here, because a rescan skips hashes it already knows.🤖 Generated with Claude Code
https://claude.ai/code/session_01QtRTdtw1SbV7ugjz5wPFgc
Generated by Claude Code