Embed
Embed copied to clipboard
Provider URL not consistent
Hey,
I'm doing some specific adjustement depending on the URL of the provider but I did notice two "similar" URL can be different such as :
https://www.reddit.com https://www.reddit.com/
I could remove the "/" by myself but I think it's better if "Embed" did it to be more consistent.
I did the same test on Embedly and they do remove it : https://embed.ly/docs/explore/extract?url=https%3A%2F%2Fwww.reddit.com%2F
I see the same result in both cases:
- https://oscarotero.com/embed/demo/index.php?url=https%3A%2F%2Fwww.reddit.com
- https://oscarotero.com/embed/demo/index.php?url=https%3A%2F%2Fwww.reddit.com%2F
Yes, my example was bad, so I tried with another Reddit URL with a path after the '/' and it happens :
https://oscarotero.com/embed/demo/index.php?url=https%3A%2F%2Fwww.reddit.com%2Fr%2FGlobalOffensive%2Fcomments%2Fjqnxoj%2Fthe_best_noscope_i_have_ever_seen%2F&settings=
Edit: Can be easily fixed like that :
$data = $embed->get($url);
$data->providerUrl->getHost();
In this case, the providerUrl value is returned by the Oembed API:

The aim of this library is return the values as is, without modify them. To normalize these values, you can use a different PSR-7 library that does it (or a helper function). Anyway, if I had to normalize this, I think it's a good practice to provide a /
at the end of the url, instead removing it (personal opinion).
I don't see the '/' at the end as an issue. If the providerUrl gave me an URL with the '/' at the end everytime I'd be happy. The only thing I'm concerned about is consistency, if one time it returns and URL with the '/' and the other time an URL without it depending on how people works with it, it may cause problems / bugs.
And while I'm here, thank you for the quick answers and this amazing project.
Edit : << Anyway, if I had to normalize this >>
Sorry I missed that part, everything's fine then, hope it'll happen 👍