You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix inconsistent file extension handling in workspaces (#1899)
* refactor(workspace): extract file extension utilities for reusability
Extracted file extension matching and replacement logic into reusable utility functions (`doesFilenameMatchExtension` and `replaceFileExtension`) to improve code consistency and maintainability.
Changes:
- Added `doesFilenameMatchExtension()` utility to standardize extension checking
- Added `replaceFileExtension()` utility to handle filename extension replacement
- Replaced inline extension matching logic across ImportWorkspaceFileModal, SequenceEditor, and effects
- Added error handling for file conversion operations
- Simplified filename manipulation in sequence editor download functionality
This refactoring reduces code duplication and provides a single source of truth for file extension operations throughout the workspace handling code.
* refactor(workspaces): replace regex with string matching for file extensions
Replace regex-based pattern matching with simple string comparison in
`doesFilenameMatchExtension` and `replaceFileExtension` functions to
avoid unintended behavior with special characters.
Changes:
- Use `endsWith()` instead of regex for extension matching
- Add support for compound extensions (e.g., 'seqn.txt')
- Use string slicing instead of regex replacement
- Add validation check before replacing extension
- Remove tests for regex special character handling
- Add tests for compound extension scenarios
This prevents issues where special regex characters in extensions
(like `*`, `+`, `.`) would be interpreted as patterns rather than
literal strings, making extension matching more predictable and correct.
---------
Co-authored-by: Dan Delany <daniel.t.delany@jpl.nasa.gov>
0 commit comments