Skip to content

Can't access sprite file by relative URL #8461

Closed

Description

@stevage

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.

Activity

  1. stevage commented on Jul 11, 2019

    @stevage
    ContributorAuthor

    Well, I guess this workaround works:

    sprite: `${window.location}sprite`
    
  2. mourner commented on Jul 11, 2019

    @mourner
    Member

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

  3. stevage commented on Jul 12, 2019

    @stevage
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions