Skip to content

fix(douban/subject): self-contained splitDoubanTitle for page.evaluate injection (#1851) - #1924

Merged
jackwener merged 1 commit into
jackwener:mainfrom
LeoLin990405:fix/douban-subject-normalizetext
Jun 13, 2026
Merged

fix(douban/subject): self-contained splitDoubanTitle for page.evaluate injection (#1851)#1924
jackwener merged 1 commit into
jackwener:mainfrom
LeoLin990405:fix/douban-subject-normalizetext

Conversation

@LeoLin990405

Copy link
Copy Markdown
Contributor

What

opencli douban subject <id> crashes with ReferenceError: normalizeText is not defined (#1851).

loadDoubanMovieSubject injects ${splitDoubanTitle.toString()} into a page.evaluate string, but splitDoubanTitle's body calls the module-level normalizeText — which doesn't exist in the page context. The serialized function loses its module closure, so the command throws every time.

ReferenceError: normalizeText is not defined
    at splitDoubanTitle (<anonymous>:5:24)

Fix

Inline a local normalizeText inside splitDoubanTitle (identical to the module helper) so the serialized function is self-contained, and export it for the regression test. The module-level normalizeText and all Node-side callers are unchanged.

Verification

Fixes #1851

…aluate injection

loadDoubanMovieSubject injects `${splitDoubanTitle.toString()}` into a
page.evaluate string, but the function body called the module-level
`normalizeText`, which does not exist in the page context — so
`opencli douban subject <id>` threw `ReferenceError: normalizeText is not
defined` (jackwener#1851).

Inline a local `normalizeText` inside `splitDoubanTitle` (equivalent to the
module helper) so the serialized function is self-contained, and export it
for the regression test. Node-side callers are unaffected.

Verified: `douban subject 37116446` returns movie details again; 4 new
regression tests reproduce the injection in a normalizeText-free scope
(red before fix, green after); `vitest run clis/douban/` → 27 passed.

Fixes jackwener#1851
@jackwener
jackwener merged commit 1c88aff into jackwener:main Jun 13, 2026
11 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.

[Bug]: opencli douban subject <id> command error, unable to query movie details

2 participants