Code Monkey home page Code Monkey logo

Comments (8)

YoranBrondsema avatar YoranBrondsema commented on May 29, 2024 2

@raae Sounds good! Thanks for following up on the issue on https://github.com/iamcal/oembed.

from gatsby-remark-oembed.

raae avatar raae commented on May 29, 2024 1

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.

from gatsby-remark-oembed.

raae avatar raae commented on May 29, 2024 1

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.

from gatsby-remark-oembed.

raae avatar raae commented on May 29, 2024 1

@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.

from gatsby-remark-oembed.

YoranBrondsema avatar YoranBrondsema commented on May 29, 2024

Yes please! Anything I can do to get the Instagram fix into a new release?

from gatsby-remark-oembed.

raae avatar raae commented on May 29, 2024

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.

from gatsby-remark-oembed.

YoranBrondsema avatar YoranBrondsema commented on May 29, 2024

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?

from gatsby-remark-oembed.

raae avatar raae commented on May 29, 2024

Working on it, help test the next version - see #159

from gatsby-remark-oembed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.