Skip to content
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

Downloading with custom provider Google with unexpected behaviour/result from Google API #69

Open
Eddict opened this issue Feb 12, 2022 · 2 comments

Comments

@Eddict
Copy link

Eddict commented Feb 12, 2022

hi, i have this url; https://www.pluimen.nl which has a (regular) favicon.

var hostname = GetValidHost(url);
rips of the https part and only the domain is passed in the next lines of code

providerURL
has a final value of https://www.google.com/s2/favicons?domain=www.pluimen.nl&sz=128

that address gets redirected to
https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://www.pluimen.nl&size=128
which leads to this default broken/not exiting pic; image

if you check that redirected url, it uses http instead of https 🤨
but the API does that for every url so i do not understand this behavior. perhaps i would if the http:// address, in this case http://www.pluimen.nl, would lead to a 404 or whatever error, but it gets redirected as expected to https://www.pluimen.nl

then i just replaced the http by https
https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://www.pluimen.nl&size=128
it leads to image (showing the 16 pixel size here for clarity)

of course you cannot do anything about this, but then i wondered if the API has some sort of parameter which can set/force https.
there is none it seems, the whole API is undocumented already anyway.

but then i tried the following (added the protocol to the domain param);
https://www.google.com/s2/favicons?domain=https://www.pluimen.nl&sz=128
and that gets redirected to
https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://www.pluimen.nl&size=128
so that way the https part gets preserved 🥳

so would it be possible to change this? so prefixing the final value of the domain parameter with the http(s):// protocol part.
thanks a lot!

regards Eddict

@navossoc
Copy link
Owner

navossoc commented Feb 12, 2022

I think you can hard code the https prefix, like this:

https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://{URL:HOST}&size={YAFD:ICON_SIZE}

You can use the placeholders that are available right now to build our own URLs.
{URL:HOST} and {YAFD:ICON_SIZE}

In the future I can try to parse the custom URL provided and expose more placeholders, like: {URL:SCM}
https://keepass.info/help/base/placeholders.html

Cheers

@Eddict
Copy link
Author

Eddict commented Feb 12, 2022

i guess you mean this? (i dont want to 'hardcode' the redirected url)
https://www.google.com/s2/favicons?domain=https://{URL:HOST}&sz={YAFD:ICON_SIZE}

nice alternative indeed, but then i force everything to https, not sure if that will ever lead to issues (although http addresses are ver rare and should be avoided anyway).

i like the placeholders idea, let me play with that! maybe i can code it myself and create a pull request when done.
thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants