protocol-agnostic approach breaks when using file: as protocol
Closed this issue · 3 comments
stetro commented
For example when using Cordova and/or Ionic the Gravatar URL of the request will look like file://www.gravatar.com/avatar/...?s=40&d=404
.
There may should be a check if http is used at all.
ng2-avatar/src/avatar.component.ts
Line 68 in 154766e
snics commented
Thank you very much of course this is a useful idea but how can the location of the protocol be verified according to your opinion?
stetro commented
My first idea would be something like:
if (window.location.protocol.startsWith('http')) {
this.gravatarUrl = `//www.gravatar.com/avatar/${hash}?s=${this.size}&d=404`;
} else {
this.gravatarUrl = `https//www.gravatar.com/avatar/${hash}?s=${this.size}&d=404`;
}
But of cause, this is not very independent of the used platform running this component.
What about adding an optional property for this?
I will provide a MR in a second.