Hard code tweet url to avoid import

This commit is contained in:
Jackson Harper
2024-01-23 23:45:28 +08:00
parent 4fce7e9287
commit f8264bfc10

View File

@ -18,7 +18,6 @@ import {
cleanUrl,
generateSlug,
stringToHash,
TWEET_URL_REGEX,
validatedDate,
wordsCount,
} from '../utils/helpers'
@ -32,7 +31,7 @@ import { createLibraryItem, updateLibraryItem } from './library_item'
// where we can use APIs to fetch their underlying content.
const FORCE_PUPPETEER_URLS = [
TWEET_URL_REGEX,
/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)(?:\/.*)?/,
/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/,
]
const ALREADY_PARSED_SOURCES = [
@ -58,7 +57,10 @@ const createSlug = (url: string, title?: string | null | undefined) => {
const shouldParseInBackend = (input: SavePageInput): boolean => {
return (
ALREADY_PARSED_SOURCES.indexOf(input.source) === -1 &&
FORCE_PUPPETEER_URLS.some((regex) => regex.test(input.url))
FORCE_PUPPETEER_URLS.some((regex) => {
console.log('REGEX: ', regex)
return regex.test(input.url)
})
)
}