Fix Twitter/X.com embed URLs with query parameters and path segments#142
Open
orbachar wants to merge 3 commits intoeditor-js:masterfrom
Open
Fix Twitter/X.com embed URLs with query parameters and path segments#142orbachar wants to merge 3 commits intoeditor-js:masterfrom
orbachar wants to merge 3 commits intoeditor-js:masterfrom
Conversation
- Updated regex to properly handle URLs with query parameters (e.g., ?s=20) - Updated regex to properly handle URLs with path segments after status ID (e.g., /photo/1) - Added test cases for x.com URLs with query parameters and path segments - Fixes issue where https://x.com URLs with additional parameters were not recognized
The previous regex only handled query parameters but not path segments. Updated to: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\/.*)?(?:\?.*)?$/ This now properly matches: - https://x.com/cb_doge/status/1817235892916146413/photo/1 - https://x.com/status/123?s=20 - https://x.com/status/123/photo/1?s=20
Author
|
Fixes: |
neSpecc
reviewed
Nov 20, 2025
Contributor
neSpecc
left a comment
There was a problem hiding this comment.
Please, attach an issue correctly. And increment a patch version
Contributor
|
Please, update branch from |
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.
Problem
Twitter/X.com URLs with query parameters or path segments after the status ID were not being recognized by the embed regex pattern.
Examples of URLs that didn't work:
https://x.com/cb_doge/status/1817235892916146413/photo/1https://x.com/MrShibolet/status/1990842843481387410?s=20Solution
Updated the Twitter service regex pattern to properly handle:
?s=20,?s=20&t=xyz)/photo/1)Changed regex from:
/^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/To:
/^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)(?:\?.*)?$/The new pattern uses
(?:\?.*)?$to optionally match query parameters and ensures the pattern matches to the end of the string, which allows for any path segments or query parameters after the status ID.Testing
Added comprehensive test cases including:
/photo/1)All existing tests continue to pass.