mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Lazyloaded @extractus/oembed-extractor
dependency
- this dependency seems a pretty heavy one to require upon boot and given most sites don't need it to function as normal, this saves several MB of RAM per instance
This commit is contained in:
parent
7639b7b69e
commit
898b55265c
2 changed files with 6 additions and 2 deletions
|
@ -1,4 +1,3 @@
|
||||||
const {extract} = require('@extractus/oembed-extractor');
|
|
||||||
const logging = require('@tryghost/logging');
|
const logging = require('@tryghost/logging');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +38,8 @@ class TwitterOEmbedProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const {extract} = require('@extractus/oembed-extractor');
|
||||||
|
|
||||||
/** @type {object} */
|
/** @type {object} */
|
||||||
const oembedData = await extract(url.href);
|
const oembedData = await extract(url.href);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const tpl = require('@tryghost/tpl');
|
const tpl = require('@tryghost/tpl');
|
||||||
const logging = require('@tryghost/logging');
|
const logging = require('@tryghost/logging');
|
||||||
const {extract, hasProvider} = require('@extractus/oembed-extractor');
|
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const charset = require('charset');
|
const charset = require('charset');
|
||||||
|
@ -19,6 +18,8 @@ const messages = {
|
||||||
* @returns {{url: string, provider: boolean}}
|
* @returns {{url: string, provider: boolean}}
|
||||||
*/
|
*/
|
||||||
const findUrlWithProvider = (url) => {
|
const findUrlWithProvider = (url) => {
|
||||||
|
const {hasProvider} = require('@extractus/oembed-extractor');
|
||||||
|
|
||||||
let provider;
|
let provider;
|
||||||
|
|
||||||
// build up a list of URL variations to test against because the oembed
|
// build up a list of URL variations to test against because the oembed
|
||||||
|
@ -95,6 +96,8 @@ class OEmbedService {
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
*/
|
*/
|
||||||
async knownProvider(url) {
|
async knownProvider(url) {
|
||||||
|
const {extract} = require('@extractus/oembed-extractor');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await extract(url);
|
return await extract(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue