Skip to content

fix: handle multi-dot filenames in fileExists extension check#1

Open
hikali123456789 wants to merge 1 commit into
masterfrom
fix/file-existence-multi-dot
Open

fix: handle multi-dot filenames in fileExists extension check#1
hikali123456789 wants to merge 1 commit into
masterfrom
fix/file-existence-multi-dot

Conversation

@hikali123456789
Copy link
Copy Markdown
Owner

@hikali123456789 hikali123456789 commented May 24, 2026

Problem

The fileExists() function in src/domains/models/SpecificationFile.ts uses name.split('.')[1] to extract the file extension. For multi-dot filenames like my.asyncapi.yaml, this retrieves 'asyncapi' instead of 'yaml', causing valid spec files to be incorrectly rejected with ErrorLoadingSpec.

Fix

Use split().pop() to get the last segment, correctly identifying the actual file extension for any number of dots.

Changes

  • src/domains/models/SpecificationFile.ts: Fixed extension extraction ??split('.')[1] replaced with split().pop()
  • test/unit/models/spec-file.test.ts: Added comprehensive unit tests covering single-dot filenames, multi-dot filenames, unsupported extensions, and edge cases

Previously, fileExists() used name.split('.')[1] to extract the file
extension, which failed for multi-dot filenames like 'my.asyncapi.yaml'
— retrieving 'asyncapi' instead of 'yaml'. This caused valid spec files
with multiple dots in their names to be rejected as having unsupported
extensions.

Fix: use split().pop() to get the last segment, correctly identifying
the actual file extension for any number of dots.
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.

1 participant