Skip to content

Fix inconsistent file extension handling in workspaces#1899

Open
duranb wants to merge 2 commits intodevelopfrom
fix/sequence-file-extension-handling
Open

Fix inconsistent file extension handling in workspaces#1899
duranb wants to merge 2 commits intodevelopfrom
fix/sequence-file-extension-handling

Conversation

@duranb
Copy link
Copy Markdown
Collaborator

@duranb duranb commented Mar 26, 2026

Addressing two issues reported by @parkerabercrombie -

  1. If I upload a file named test.SEQ.json I don’t get the option to translate to seqN, but if it’s called test.seq.json I do (case sensitivity)
  2. If I name my file test.seqn.txt and download as SeqJSON I get a file called test.seqn.seq.json - should be test.seq.json

Verification

To test upload issue:

  1. Create a workspace (no adaptation necessary)
  2. Upload a file with the output extension that doesn't quite match the case specified in the adaptation (e.g. test1.SEQ.json)
  3. Verify that you are prompted with a choice to convert to the input extension (e.g. .seqN.txt)
  4. Check on the checkbox to convert
  5. Confirm the upload
  6. Verify that the file added has the expected filename (e.g. test1.seqN.txt)

To test download issue:

  1. Open a file with the input extension (e.g. test1.seqN.txt)
  2. Click the Output button above the SequenceEditor
  3. Select one of the download options
  4. Verify that the file downloaded has the correct filename

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.
@duranb duranb requested a review from a team as a code owner March 26, 2026 21:27
@duranb duranb temporarily deployed to test-workflow March 26, 2026 21:27 — with GitHub Actions Inactive
@duranb duranb temporarily deployed to test-workflow March 26, 2026 22:29 — with GitHub Actions Inactive
…ensions

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.
@duranb duranb temporarily deployed to test-workflow March 27, 2026 20:30 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants