url provider should force http/https
Closed this issue · 9 comments
I try to use your plugin in chrome extension.
Since url templates looks like url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', it failed to load tiles because under chrome:// protocol
I suppose your template is to stay in the same protocol as the website, but then can you add a test on current location.protocol and add a fallback as http ?
var protocol = /https?/.test(location.protocol)?location.protocol:'http';
Hmm, makes sense to whitelist only http
and https
, but should we fall back to http or https? Thoughs @brunob?
@jieter ok, we could do something inspired by what i do in bing layer plugin, fall back to http when the page is on file:// protocol see :
https://github.com/shramov/leaflet-plugins/blob/master/layer/tile/Bing.js#L54
warning : as I mentioned, in Chrome extension scope, this is chrome:// protocol, not file:// !
@ludoo0d0a if you look at the code i'm pointing, you'll see that it use http only if the protocol of the page is file, in the other cases it stay in the document protocol.
yes, that's the problem ;)
Here the result in console in a chrome extension...
>(document.location.protocol === 'file:') ? 'http' : document.location.protocol.slice(0, -1);
>"chrome-extension"
if urlScheme stay the same as document.location.protocol, you never could reach our remote content...
note protocol is chrome-extension:// in extension and chrome:// in chrome app (from what i remember)
Ha my bad, so we just have to adapt the test a bit. Anyway, i was pointing this code in order to not forget users who will try to use the script locally (since https by default will break this use case).
pas de souci 😜
@ludoo0d0a do you have a patch to propose or should we get on this ?