-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a new release #145
Comments
Yes please! Anything I can do to get the Instagram fix into a new release? |
A new release does not fix Instagram, one has to add an access_token to the Setting to do so. See the updated readme. I should of course also get on with making a new release as well. I might reach out to you to test the new release before releasing. |
I see that the order of Instagram endpoints have been changed in the provider list this plugin rely on, meaning the deprecated endpoint is now favoured. I do not understand why it is in there at all, I will make a PR against @iamcal/oembed. So even with adding an access_token it will be broken right now. I am thinking more and more that I might need to keep my own vetted list, or get more involved with that repo as well. |
I agree, it's confusing that in https://github.com/iamcal/oembed/blob/1db773d2665db51101776744f04a0a15b0086bdc/providers/instagram.yml a same URL can match multiple endpoints. It does seem like the schemes in @iamcal/oembed are sorted by order of preference though. So the first match should be the "correct" one. If that's the assumption, then it would make sense to rewrite https://github.com/raae/gatsby-remark-oembed/blob/master/gatsby-remark-oembed/utils/getProviderEndpointForLinkUrl.js as: const getProviderEndpointForLinkUrl = (linkUrl, providers) => {
for (const provider of providers || []) {
for (const endpoint of provider.endpoints || []) {
const isInstagram = provider.provider_name === "Instagram";
const hasAccessToken = provider.params && provider.params.access_token;
for (let schema of endpoint.schemes || []) {
schema = schema.replace("*", ".*");
const regExp = new RegExp(schema);
const isMatchingSchema = regExp.test(linkUrl);
if (isMatchingSchema && isInstagram && !hasAccessToken) {
throw new Error(
"Instagram require you to configure an access_token. For more information, visit https://developers.facebook.com/docs/instagram/oembed/."
);
} else if (isMatchingSchema) {
return {
url: endpoint.url,
params: {
url: linkUrl,
...provider.params
}
};
}
}
}
}
return {};
}; so return early as soon as a match is found. Would that make sense? |
The deprecated endpoint has been removed (iamcal/oembed#515), it should be reflected in the provider list within an hour and Instagram embed should work again if you provide an access_token. |
@YoranBrondsema I would like to do a complete refactor of the code you reference as this was my first ever node project and I have learned a lot since then. Therefore I do not think we need to update this now as all providers should have only one match for the foreseeable future. However when I get around to diagramming the refactor and roadmap for this plugin I would love to have you contribute. |
@raae Sounds good! Thanks for following up on the issue on https://github.com/iamcal/oembed. |
Working on it, help test the next version - see #159 |
No description provided.
The text was updated successfully, but these errors were encountered: