Embed icon indicating copy to clipboard operation
Embed copied to clipboard

Provider URL not consistent

Open Soonz opened this issue 4 years ago • 4 comments

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

Soonz avatar Nov 08 '20 09:11 Soonz

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

oscarotero avatar Nov 09 '20 10:11 oscarotero

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();

Soonz avatar Nov 09 '20 11:11 Soonz

In this case, the providerUrl value is returned by the Oembed API:

imaxe

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

oscarotero avatar Nov 09 '20 12:11 oscarotero

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 👍

Soonz avatar Nov 09 '20 12:11 Soonz