|
@@ -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')
|