Open raae opened 4 years ago
We do have a step where the provider list is prepped for use, maybe change the structure of it so its easier to match url with schema.
Ie. going from this:
[
{
provider_name: "Twitter",
provider_url: "http://www.twitter.com/",
endpoints: [
{
schemes: [
"https://twitter.com/*/status/*",
"https://*.twitter.com/*/status/*"
],
url: "https://publish.twitter.com/oembed"
}
]
}
]
to this:
[
{
scheme: "https://twitter.com/*/status/*",
provider_name: "Twitter",
provider_url: "http://www.twitter.com/",
endpoint: "https://publish.twitter.com/oembed"
},
{
scheme: "https://*.twitter.com/*/status/*",
provider_name: "Twitter",
provider_url: "http://www.twitter.com/",
endpoint: "https://publish.twitter.com/oembed"
}
]
Then we could loop through once per oEmbed link, and can break out of the loop as soon as we find it.
The code in this function has three nested loops, so it's O(n3) (cubic time). We can probably improve upon this.
_Originally posted by @nickytonline in https://github.com/raae/gatsby-remark-oembed/pull/132#discussion_r519533630_