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

url provider should force http/https #227

Closed
ludoo0d0a opened this issue Aug 23, 2016 · 9 comments
Closed

url provider should force http/https #227

ludoo0d0a opened this issue Aug 23, 2016 · 9 comments

Comments

@ludoo0d0a
Copy link

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';
@jieter
Copy link
Contributor

jieter commented Dec 6, 2016

Hmm, makes sense to whitelist only http and https, but should we fall back to http or https? Thoughs @brunob?

@brunob
Copy link
Member

brunob commented Dec 7, 2016

@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

@ludoo0d0a
Copy link
Author

warning : as I mentioned, in Chrome extension scope, this is chrome:// protocol, not file:// !

@brunob
Copy link
Member

brunob commented Dec 7, 2016

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

@ludoo0d0a
Copy link
Author

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)

@brunob
Copy link
Member

brunob commented Dec 7, 2016

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

@ludoo0d0a
Copy link
Author

pas de souci 😜

@brunob
Copy link
Member

brunob commented Feb 20, 2017

@ludoo0d0a do you have a patch to propose or should we get on this ?

@brunob
Copy link
Member

brunob commented Feb 4, 2018

Fixed by #258

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

3 participants