Skip to content

fix(code-block): match download extensions case-insensitively - #712

Merged
farnabaz merged 1 commit into
vercel:mainfrom
Manishram-ai:fix/code-download-extension-case
Nov 4, 2026
Merged

farnabaz merged 1 commit into
vercel:mainfrom
Manishram-ai:fix/code-download-extension-case

Conversation

@Manishram-ai

Copy link
Copy Markdown
Contributor

Description

The code block download button looks up the file extension with language in languageExtensionMap, which is case-sensitive and also matches keys on Object.prototype. The highlighter lowercases the language, so ```Python is highlighted fine but downloads as file.txt, and ```constructor downloads as file.function Object() { [native code] }.

This lowercases the language before the lookup and uses Object.hasOwn, like markdown.ts already does.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Changes Made

  • download-button.tsx: lowercase the language and check own keys only
  • tests for Python, JSON and TypeScript, and for constructor, toString and __proto__ falling back to .txt
  • patch changeset

Testing

  • All existing tests pass
  • Added new tests for the changes

The 6 new tests fail on main and pass with this change. The full streamdown suite passes (1,316 tests), and Biome is clean on the changed files.

Checklist

  • My code follows the project's code style
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have created a changeset (pnpm changeset)
  • All my commits are signed

Changeset

  • I have created a changeset for these changes

@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@Manishram-ai is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@farnabaz farnabaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks

@farnabaz
farnabaz merged commit 4e2c00a into vercel:main Nov 4, 2026
8 of 9 checks passed
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