Skip to content

fix: ensure magnet link is string before parsing#1400

Open
xiaoxinmm wants to merge 1 commit into
6c65726f79:mainfrom
xiaoxinmm:fix/issue-1384
Open

fix: ensure magnet link is string before parsing#1400
xiaoxinmm wants to merge 1 commit into
6c65726f79:mainfrom
xiaoxinmm:fix/issue-1384

Conversation

@xiaoxinmm

Copy link
Copy Markdown

Summary

Fixes #1384

Problem

When adding certain magnet links, parseTorrent() throws t.charCodeAt is not a function. This happens because in some edge cases (e.g. drag-and-drop, protocol handler callbacks), the magnet value passed to readMagnets() may not be a plain string.

Fix

Added explicit string coercion before passing the value to parseTorrent():

const magnetStr = typeof magnet === 'string' ? magnet : String(magnet);

Closes #1384

parseTorrent() expects a string but in some cases the magnet value
could be a non-string type, causing 'charCodeAt is not a function'.
Add explicit string coercion before passing to parseTorrent.
@sonarqubecloud

sonarqubecloud Bot commented Mar 1, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

Error "t.charCodeAt is not a function" when adding some specific magnetic link

1 participant