This commit is contained in:
Peter Zdravecký 2025-03-20 16:42:47 +01:00 committed by GitHub
commit 40e4c232ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -119,7 +119,11 @@ function getUrlObject(req) {
*/
export function getPublicUrl(publicUrl, req) {
if (publicUrl) {
return publicUrl;
try {
return new URL(publicUrl).toString();
} catch {
return new URL(publicUrl, getUrlObject(req)).toString();
}
}
return getUrlObject(req).toString();
}

View file

@ -25,7 +25,7 @@ describe('Styles', function () {
expect(res.body.sources).to.be.a('object');
expect(res.body.glyphs).to.be.a('string');
expect(res.body.sprite).to.be.a('string');
expect(res.body.sprite).to.be.equal('/test/styles/test-style/sprite');
expect(res.body.sprite).to.contain('/test/styles/test-style/sprite');
expect(res.body.layers).to.be.a('array');
})
.end(done);