Remove obscure embed attribute and remove cache

The cache is a possible memory leak: It grows over time and never gets
cleaned.
This commit is contained in:
Robert Schäfer 2019-07-20 15:54:59 +02:00
parent 7a9d9339f8
commit d81c38c4e3
2 changed files with 0 additions and 23 deletions

View File

@ -31,9 +31,6 @@ const metascraper = Metascraper([
// require('./rules/metascraper-embed')()
])
// quick in memory cache
let cache = {}
let oEmbedProviders = []
const getEmbedProviders = async () => {
let providers = await request('https://oembed.com/providers.json')
@ -92,12 +89,6 @@ export default async function scrape(targetUrl) {
targetUrl.hostname = 'youtube.com'
}
if (cache[targetUrl]) {
return cache[targetUrl]
}
const url = new URL(targetUrl)
let meta = {}
let embed = {}
@ -137,18 +128,5 @@ export default async function scrape(targetUrl) {
throw new ApolloError('Not found', 'NOT_FOUND')
}
// fix youtube start parameter
const YouTubeStartParam = url.searchParams.t || url.searchParams.start
if (output.publisher === 'YouTube' && YouTubeStartParam) {
output.embed = output.embed.replace(
'?feature=oembed',
`?feature=oembed&start=${YouTubeStartParam}`,
)
output.url += `&start=${YouTubeStartParam}`
}
// write to cache
cache[targetUrl] = output
return output
}

View File

@ -11,7 +11,6 @@ type Embed {
video: String
lang: String
logo: String
embed: String
sources: [String]
}