diff --git a/src/utils.js b/src/utils.js index 5dab80a..3b242b8 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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(); } diff --git a/test/style.js b/test/style.js index 469eab7..f2af4fb 100644 --- a/test/style.js +++ b/test/style.js @@ -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);