Update twitter url regexs to match x.com or twitter.com (#454)

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
This commit is contained in:
SatsAllDay 2023-08-30 21:13:43 -04:00 committed by GitHub
parent 61485d38b5
commit 1872d6a7ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -68,7 +68,7 @@ function ItemEmbed ({ item }) {
const [overflowing, setOverflowing] = useState(false)
const [show, setShow] = useState(false)
const twitter = item.url?.match(/^https?:\/\/twitter\.com\/(?:#!\/)?\w+\/status(?:es)?\/(?<id>\d+)/)
const twitter = item.url?.match(/^https?:\/\/(?:twitter|x)\.com\/(?:#!\/)?\w+\/status(?:es)?\/(?<id>\d+)/)
if (twitter?.groups?.id) {
return (
<div className={`${styles.twitterContainer} ${show ? '' : styles.twitterContained}`}>

View File

@ -15,7 +15,7 @@ export function removeTracking (value) {
if (!value) return value
const exprs = [
// twitter URLs
/^(?<url>https?:\/\/twitter\.com\/(?:#!\/)?(?<user>\w+)\/status(?:es)?\/(?<id>\d+))/
/^(?<url>https?:\/\/(?:twitter|x)\.com\/(?:#!\/)?(?<user>\w+)\/status(?:es)?\/(?<id>\d+))/
]
for (const expr of exprs) {
value = expr.exec(value)?.groups.url ?? value