diff --git a/modules/tiles/src/tileset/tileset-3d.ts b/modules/tiles/src/tileset/tileset-3d.ts index ee34c2f2a6..1ccdb3696e 100644 --- a/modules/tiles/src/tileset/tileset-3d.ts +++ b/modules/tiles/src/tileset/tileset-3d.ts @@ -348,7 +348,12 @@ export class Tileset3D { if (isDataUrl) { return tilePath; } - return `${tilePath}${tilePath.includes('?') ? '&' : '?'}${this.queryParams}`; + + let tileUrl = tilePath; + if (this.queryParams.length) { + tileUrl = `${tilePath}${tilePath.includes('?') ? '&' : '?'}${this.queryParams}`; + } + return tileUrl; } // TODO CESIUM specific diff --git a/modules/tiles/test/tileset/tileset-3d.spec.ts b/modules/tiles/test/tileset/tileset-3d.spec.ts index 212179bc7c..55b9bccb37 100644 --- a/modules/tiles/test/tileset/tileset-3d.spec.ts +++ b/modules/tiles/test/tileset/tileset-3d.spec.ts @@ -162,12 +162,23 @@ test('Tileset3D#url set up correctly given path with query string', async (t) => '/test/data/Tilesets/TilesetOfTilesets/tileset2.json?param3=3&session=sesh¶m1=1¶m2=2&v=1.2.3', 'child url content parameters preserved' ); + const urlEnds = tileset.getTileUrl(tile.contentUrl).slice(-1); + t.equals('?&'.includes(urlEnds), false); } else { t.fail('no tile'); } t.end(); }); +test('Tileset3D#getTileUrl should not ends with sign ? or &', async (t) => { + const path = '@loaders.gl/3d-tiles/test/data/Tilesets/TilesetOfTilesets/tileset2.json'; + const tilesetJson = await load(path, Tiles3DLoader); + const tileset = new Tileset3D(tilesetJson); + const urlEnds = tileset.getTileUrl(tileset.url).slice(-1); + t.equals('?&'.includes(urlEnds), false); + t.end(); +}); + test('Tileset3D#loads and initializes with tileset JSON file', async (t) => { const tilesetJson = await load(TILESET_URL, Tiles3DLoader); const tileset = new Tileset3D(tilesetJson);