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

Unable load sprites from file:/// schema. #4648

Closed
oscarfonts opened this issue Apr 27, 2017 · 0 comments
Closed

Unable load sprites from file:/// schema. #4648

oscarfonts opened this issue Apr 27, 2017 · 0 comments

Comments

@oscarfonts
Copy link
Contributor

mapbox-gl-js version: 0.36.0 (and master at the time of writing)

Steps to Trigger Behavior

  1. Configure a style with a sprite url starting with "file:///"
  2. Instantiate a Map

Expected Behavior

Load the sprites and use them.

Actual Behavior

Sprites are not shown. Error thrown:

 Error: Unable to parse URL object
      at parseUrl (src/util/mapbox.js:104:15)
      at Object.exports.normalizeSpriteURL (src/util/mapbox.js:64:23)

Origin

The origin of the error is a regular expression urlRe defined in src/util/mapbox.js, which doesn't match file:///path:

/^(\w+):\/\/([^/?]+)(\/[^?]+)?\??(.+)?/

It expects the "host" part of the URL (2nd capture group) to have some value, but in fact it can be empty (as in this case).

Fixture

Making the 2nd capture group optional would fix the issue.
Will provide a PR with the test case and a patch.

@oscarfonts oscarfonts changed the title Unable load local sprites loaded from file:// schema. Unable load sprites from file:// schema. Apr 27, 2017
@oscarfonts oscarfonts changed the title Unable load sprites from file:// schema. Unable load sprites from file:/// schema. Apr 27, 2017
@mourner mourner closed this as completed Apr 27, 2017
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

2 participants