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

Base URL formatted incorrectly #47

Open
somemothersson opened this issue Aug 19, 2019 · 3 comments
Open

Base URL formatted incorrectly #47

somemothersson opened this issue Aug 19, 2019 · 3 comments

Comments

@somemothersson
Copy link

somemothersson commented Aug 19, 2019

var baseURL,fix leading // to instead be https://
when gravatar url is created via gravatar.url(email) the url is generated as //www.gravatar.com when should be https://www.gravatar.com

line 32 gravatar.js

var gravatar = module.exports = {

    url: function (email, options, protocol) {
      var baseURL = "//www.gravatar.com/avatar/";
      if (options && options.cdn) {
        baseURL = options.cdn + '/avatar/';
        delete options.cdn;
      } else {
        if (options && options.protocol) protocol = proto(options);
        if(typeof protocol !== 'undefined') {
          baseURL = protocol ? "https://s.gravatar.com/avatar/" : 'http://www.gravatar.com/avatar/';
        }
      }
      var query = getQueryString(options);
      return baseURL + getHash(email) + query;
    },
@bushblade
Copy link

bushblade commented Mar 26, 2020

I can confirm this issue.
We already have normalize-url installed in our project so used that to get a valid url.

@dantman
Copy link

dantman commented Aug 5, 2020

Do note that //www.gravatar.com/ is still a valid href. It is a protocol relative url, i.e. on http://example.com the link will resolve to http://www.gravatar.com/.

@emerleite
Copy link
Owner

@somemothersson do you suggest to always use https?

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

4 participants