maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.74k stars 723 forks source link

Sprite url gets validated before transformRequest #3897

Open Kai-W opened 8 months ago

Kai-W commented 8 months ago

I was experimenting with relative URLs in styles and transforming all relative URLs to absoulte ones with the transformRequst Method. Unfortunatly the loading of Sprites failes with an invalid URL Error (because its relative) before the transformRequest Method gets called. https://github.com/maplibre/maplibre-gl-js/blob/f6035db6670de1af2d294e3cb5f6702f8616b53f/src/style/load_sprite.ts#L31C54-L31C70

maplibre-gl-js version: 4.1.1

browser: Chrome Version 123.0.6312.59

Steps to Trigger Behavior

  1. Load a Stylesheet with realative urls
  2. add transformRequest to transform relative to absoulte URLs
  3. Error: Unable to parse URL "/test" (url before transform)

Link to Demonstration

https://jsbin.com/ranucez/edit?html,console,output

Expected Behavior

transformRequest should be called bevor any checks if the URL is valid, eg a relative one

Actual Behavior

Error: Unable to parse URL "/maps/streets/sprite" and transformRequest never gets called for Sprites

HarelM commented 8 months ago

Feel free to submit a PR with a fix.

HarelM commented 6 months ago

Can you maybe share the transform request method for the relative urls? I think the following issue describes a similar issue: