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

Can't access sprite file by relative URL #8461

Closed
stevage opened this issue Jul 11, 2019 · 3 comments
Closed

Can't access sprite file by relative URL #8461

stevage opened this issue Jul 11, 2019 · 3 comments

Comments

@stevage
Copy link
Contributor

stevage commented Jul 11, 2019

mapbox-gl-js version: 1.1.0

I'm wanting to use a self-hosted sprite file, available at /[email protected] and /[email protected] on the domain where I'm hosting the site.

Putting this in my style file doesn't work:

            sprite: '/sprite'

Error: Unable to parse URL object

These also fail: sprite, http:///sprite, ./sprite.

Is there another way to achieve this, or are relative URLs just not supported for sprite files?

This is problematic because it makes deploying more work: I need code that detects whether running locally (localhost:8080//...) or on the deployed site, and now I also need to know the deployed site's URL.

@stevage
Copy link
Contributor Author

stevage commented Jul 11, 2019

Well, I guess this workaround works:

sprite: `${window.location}sprite`

@mourner
Copy link
Member

mourner commented Jul 11, 2019

We don't support relative URLs intentionally — see the discussion at #3636 and linked tickets.

@mourner mourner closed this as completed Jul 11, 2019
@stevage
Copy link
Contributor Author

stevage commented Jul 12, 2019

Thanks for the context. Interesting rationale. Makes sense that a style file needs to work in contexts other than web, I guess.

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