BUG: Windows path separator breaks image filename search in AddImagesToAlbumDialog
Is there an existing issue for this?
- [x] I have searched the existing issues
What happened?
What happened?
Problem Statement
In AddImagesToAlbumDialog.tsx, the search filter extracts the filename by splitting the path string exclusively on the POSIX forward slash (/). On Windows systems where paths use backslashes (\), the split fails. Consequently, fileName evaluates to the entire absolute file path rather than the basename.
This causes two issues:
- Searching for an image by its filename fails or produces unexpected results.
- Searching for a directory name (e.g., "Pictures" or "Vacation") causes all images inside that folder to match as false positives.
Inconsistency and Root Cause
Within frontend/src/components/Albums/AddImagesToAlbumDialog.tsx, two conflicting path-splitting approaches exist:
-
Search filtering logic (Line 96):
const filteredImages = allImages.filter((image) => { const searchLower = searchQuery.toLowerCase(); const fileName = image.path.split('/').pop()?.toLowerCase() || ''; return fileName.includes(searchLower); });Here, splitting on
'/'fails on Windows paths such asC:\Users\Username\Pictures\photo.jpg. -
Accessibility label logic (Line 142 of the same file):
aria-label={ image.path.split(/[/\\]/).pop() || 'Untitled image' }Here, the regular expression
/[/\\]/correctly accounts for both forward slashes and backslashes.
Other components in the repository also standardize on /[/\\]/ for cross-platform path parsing:
frontend/src/components/Media/MediaInfoPanel.tsx(Line 58)frontend/src/components/Media/ImageCard.tsx(Line 62)frontend/src/components/VideoPlayer/VideoInfoPanel.tsx(Line 46)
Visual Proof
Steps to Reproduce
- Run PictoPy on Windows (or index files containing backslashes in their path).
- Open Albums and navigate into any album.
- Click "Add Images" to open
AddImagesToAlbumDialog. - In the search input, enter a parent folder name (e.g., a directory segment present in the path).
- Observe that images under that directory are matched as false positives, while exact filename filtering behaves inconsistently.
Expected Behavior
The search filter should extract only the file basename across all supported operating systems (Windows, macOS, Linux) by splitting on both / and \.
Actual Behavior
On Windows, fileName evaluates to the complete absolute path because backslashes are not recognized as path separators.
Proposed Solution
Update line 96 in frontend/src/components/Albums/AddImagesToAlbumDialog.tsx to use the same regular expression pattern present on line 142:
const fileName = image.path.split(/[/\\]/).pop()?.toLowerCase() || '';
I have verified the root cause and would like to submit a PR to resolve this if assigned.
Record
- [x] I agree to follow this project's Code of Conduct
👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)
Hi @rohan-pandeyy, Can you assign this to me!
Hi @rohan-pandeyy, I've identified the root cause: Windows path separators () break image filename searches inside AddImagesToAlbumDialog. I'm ready to implement a cross-platform path handling fix for this. Could you please assign it to me?
Hi! maintainer I'd like to work on this issue if it's still open. I'm a CS undergrad getting started with open source and aiming for GSoC 2027. I've gone through the issue and the AddImagesToAlbumDialog code. My plan is to find where the filename is taken from the full path and make it handle both / and \ separators, then add a small test with Windows-style paths so the fix is covered. I'll keep the change focused and add before/after screenshots or test output in the PR.
Could you assign it to me? I'll wait for your go-ahead before opening a PR. Thanks!
@rohan-pandeyy thank you for aassigning me the issue i am currently studying the codebase , within 3 - 4 working days i will work on it .
I’m enjoying contributing to PictoPy and would be very interested in exploring GSoC opportunities with AOSSIE-Org. I’d appreciate any guidance on how to prepare and contribute meaningfully ahead of the program.