fix(toutiao): fix NON_TITLE_LINES scope error in articles parser#1179
Open
sontjer wants to merge 1 commit intojackwener:mainfrom
Open
fix(toutiao): fix NON_TITLE_LINES scope error in articles parser#1179sontjer wants to merge 1 commit intojackwener:mainfrom
sontjer wants to merge 1 commit intojackwener:mainfrom
Conversation
NON_TITLE_LINES was defined outside parseToutiaoArticlesText() as a module-level const. When the function is serialized via .toString() and injected into browser evaluate context, outer scope variables are not available, causing 'NON_TITLE_LINES is not defined' error. Fix: move NON_TITLE_LINES inside the function so it's included in the serialized string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Description
When running
opencli toutiao articles, the command fails with:Root Cause
NON_TITLE_LINESis defined as a module-levelconstoutsideparseToutiaoArticlesText(). The function is serialized via.toString()and injected into the browser'sevaluatecontext for DOM parsing. Outer scope variables are not available in the injected execution context, causing the ReferenceError.Fix
Move
NON_TITLE_LINESinside theparseToutiaoArticlesTextfunction so it's included in the serialized string.Verification
Works correctly after the fix. Command was completely broken before.