Alex Xu 8 months ago
parent
commit
dbc67e7bef
1 changed files with 2 additions and 3 deletions
  1. 2 3
      src/services/twitterService/index.ts

+ 2 - 3
src/services/twitterService/index.ts

@@ -38,13 +38,12 @@ async function refreshAccessToken(): Promise<void> {
   await saveAccessToken(token.token)
 }
 
-const tweetUrlReg =
-  /^https:\/\/x\.com\/[a-zA-Z0-9_]+\/status\/([0-9]+)(\?=.*)?$/
+const tweetUrlReg = /^https:\/\/x\.com\/[a-zA-Z0-9_]+\/status\/([0-9]+)$/
 
 const removeScriptReg = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi
 
 async function genenrateTweetByPublishAPI(urlRaw: string): Promise<Tweet> {
-  const url = urlRaw.trim()
+  const url = urlRaw.trim().split('?')[0]
   const match = url.match(tweetUrlReg)
   if (!match) {
     throw new Error('Invalid tweet URL')