mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Fixed no-shadow linting errors in oembed controllers
This commit is contained in:
parent
1d49cba426
commit
5aa6a3dbad
2 changed files with 12 additions and 12 deletions
|
@ -125,10 +125,10 @@ function fetchOembedData(_url) {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
timeout: 2 * 1000,
|
timeout: 2 * 1000,
|
||||||
followRedirect: true
|
followRedirect: true
|
||||||
}).then((response) => {
|
}).then((pageResponse) => {
|
||||||
// url changed after fetch, see if we were redirected to a known oembed
|
// url changed after fetch, see if we were redirected to a known oembed
|
||||||
if (response.url !== url) {
|
if (pageResponse.url !== url) {
|
||||||
({url, provider} = findUrlWithProvider(response.url));
|
({url, provider} = findUrlWithProvider(pageResponse.url));
|
||||||
if (provider) {
|
if (provider) {
|
||||||
return knownProvider(url);
|
return knownProvider(url);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ function fetchOembedData(_url) {
|
||||||
// check for <link rel="alternate" type="application/json+oembed"> element
|
// check for <link rel="alternate" type="application/json+oembed"> element
|
||||||
let oembedUrl;
|
let oembedUrl;
|
||||||
try {
|
try {
|
||||||
oembedUrl = cheerio('link[type="application/json+oembed"]', response.body).attr('href');
|
oembedUrl = cheerio('link[type="application/json+oembed"]', pageResponse.body).attr('href');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return unknownProvider(url);
|
return unknownProvider(url);
|
||||||
}
|
}
|
||||||
|
@ -154,10 +154,10 @@ function fetchOembedData(_url) {
|
||||||
json: true,
|
json: true,
|
||||||
timeout: 2 * 1000,
|
timeout: 2 * 1000,
|
||||||
followRedirect: true
|
followRedirect: true
|
||||||
}).then((response) => {
|
}).then((oembedResponse) => {
|
||||||
// validate the fetched json against the oembed spec to avoid
|
// validate the fetched json against the oembed spec to avoid
|
||||||
// leaking non-oembed responses
|
// leaking non-oembed responses
|
||||||
const body = response.body;
|
const body = oembedResponse.body;
|
||||||
const hasRequiredFields = body.type && body.version;
|
const hasRequiredFields = body.type && body.version;
|
||||||
const hasValidType = ['photo', 'video', 'link', 'rich'].includes(body.type);
|
const hasValidType = ['photo', 'video', 'link', 'rich'].includes(body.type);
|
||||||
|
|
||||||
|
|
|
@ -83,10 +83,10 @@ function fetchOembedData(_url) {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
timeout: 2 * 1000,
|
timeout: 2 * 1000,
|
||||||
followRedirect: true
|
followRedirect: true
|
||||||
}).then((response) => {
|
}).then((pageResponse) => {
|
||||||
// url changed after fetch, see if we were redirected to a known oembed
|
// url changed after fetch, see if we were redirected to a known oembed
|
||||||
if (response.url !== url) {
|
if (pageResponse.url !== url) {
|
||||||
({url, provider} = findUrlWithProvider(response.url));
|
({url, provider} = findUrlWithProvider(pageResponse.url));
|
||||||
if (provider) {
|
if (provider) {
|
||||||
return knownProvider(url);
|
return knownProvider(url);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ function fetchOembedData(_url) {
|
||||||
// check for <link rel="alternate" type="application/json+oembed"> element
|
// check for <link rel="alternate" type="application/json+oembed"> element
|
||||||
let oembedUrl;
|
let oembedUrl;
|
||||||
try {
|
try {
|
||||||
oembedUrl = cheerio('link[type="application/json+oembed"]', response.body).attr('href');
|
oembedUrl = cheerio('link[type="application/json+oembed"]', pageResponse.body).attr('href');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return unknownProvider(url);
|
return unknownProvider(url);
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,10 @@ function fetchOembedData(_url) {
|
||||||
json: true,
|
json: true,
|
||||||
timeout: 2 * 1000,
|
timeout: 2 * 1000,
|
||||||
followRedirect: true
|
followRedirect: true
|
||||||
}).then((response) => {
|
}).then((oembedResponse) => {
|
||||||
// validate the fetched json against the oembed spec to avoid
|
// validate the fetched json against the oembed spec to avoid
|
||||||
// leaking non-oembed responses
|
// leaking non-oembed responses
|
||||||
const body = response.body;
|
const body = oembedResponse.body;
|
||||||
const hasRequiredFields = body.type && body.version;
|
const hasRequiredFields = body.type && body.version;
|
||||||
const hasValidType = ['photo', 'video', 'link', 'rich'].includes(body.type);
|
const hasValidType = ['photo', 'video', 'link', 'rich'].includes(body.type);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue