Added config

This commit is contained in:
chris
2022-05-23 17:52:33 +08:00
parent 4f52d5b3d5
commit 6bc72e6730
5 changed files with 615 additions and 44 deletions

14
upload.ts Normal file
View File

@@ -0,0 +1,14 @@
export const getTweetID = (src: string): string => {
// Create a URL object with the source. If it fails, it's not a URL.
const url = new URL(src)
const id = url.pathname
.split('/')
.filter(piece => !!piece) // remove empty strings from array
.slice(-1)[0]
if (!id) {
throw new Error('URL does not seem to be a tweet.')
}
return id
}