Skip to content

Commit

Permalink
fix: getting tile url with empty query params (#2671)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkuznetsov-actionengine authored Oct 4, 2023
1 parent ece5138 commit 0ca40cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/tiles/src/tileset/tileset-3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions modules/tiles/test/tileset/tileset-3d.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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&param1=1&param2=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);
Expand Down

0 comments on commit 0ca40cb

Please sign in to comment.