mirror of
https://github.com/Leaflet/Leaflet.git
synced 2026-02-01 17:27:23 +00:00
TileLayer: fix Safari 16.5 compatibility (#9992)
This commit is contained in:
parent
14ca480c43
commit
bc29e77ac3
@ -406,6 +406,23 @@ describe('TileLayer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('supports relative tile URLs', () => {
|
||||
const layer = new TileLayer('./tiles/{z}/{y}/{x}.png').addTo(map);
|
||||
|
||||
const urls = [
|
||||
'./tiles/2/1/1.png',
|
||||
'./tiles/2/1/2.png',
|
||||
'./tiles/2/2/1.png',
|
||||
'./tiles/2/2/2.png'
|
||||
];
|
||||
|
||||
let i = 0;
|
||||
eachImg(layer, (img) => {
|
||||
expect(img.src).to.contain(urls[i].slice(1));
|
||||
i++;
|
||||
});
|
||||
});
|
||||
|
||||
it('adds OSM attribution if none are provided and is using OSM tiles', () => {
|
||||
// Uses OSM tiles without providing attribution
|
||||
const layer = new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {}).addTo(map);
|
||||
|
||||
@ -95,8 +95,8 @@ export class TileLayer extends GridLayer {
|
||||
options = Util.setOptions(this, options);
|
||||
|
||||
// in case the attribution hasn't been specified, check for known hosts that require attribution
|
||||
if (options.attribution === null && URL.canParse(url)) {
|
||||
const urlHostname = new URL(url).hostname;
|
||||
if (options.attribution === null) {
|
||||
const urlHostname = new URL(url, location.href).hostname;
|
||||
|
||||
// check for Open Street Map hosts
|
||||
const osmHosts = ['tile.openstreetmap.org', 'tile.osm.org'];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user