Repository navigation
Fix ajax when loading local files on iOS web view - #6610
Conversation
mourner
left a comment
There was a problem hiding this comment.
@oscarfonts looks like this PR has gone askew. Can you rebase on master and make sure the PR only contains the commit you added?
I'm also not sure this should be fixed on the GL JS side since it follows the specs, and requesting file:// files with Ajax is usually prohibited due to security restrictions. Could there be a workaround on the Cordova/app side instead?
9ea7464 to
4031b50
Compare
|
Cleared PR with rebase. Thanks! Didn't find a simpler way to pass a local (offline) resource to mapbox-gl. Alternatives were: either forking the library to replace ajax calls with some other (non-http, probably environment specific) mechanism to access local resources, or embedding a local http server into the App. I can keep my fork if you feel this too hacky, I just thought it could go upstream for a more offline-friendly library, so to speak. |
|
@oscarfonts is the way Cordova behaves with Ajax + local files (e.g. the 0 status code) documented somewhere? |
|
@oscarfonts sorry for a delay — maybe let's just accept
The docs suggest that |
|
@mourner ok, done |
When running in iOS webview (cordova app), we detected that loading local resources (
file:///...urls) is returning a "0" status code (instead of "200 OK").Included this case in util.ajax, so local files are fetched without checking the response status code value.
Tried to add a unit test, but sinon's FakeXMLHttpRequest doesn't provide the standard responseURL property we are reading. At least made sure actual unit tests are passing. :)