Merge 0053c5cd65
into cd613e2fb5
This commit is contained in:
commit
40e4c232ed
2 changed files with 6 additions and 2 deletions
|
@ -119,7 +119,11 @@ function getUrlObject(req) {
|
||||||
*/
|
*/
|
||||||
export function getPublicUrl(publicUrl, req) {
|
export function getPublicUrl(publicUrl, req) {
|
||||||
if (publicUrl) {
|
if (publicUrl) {
|
||||||
return publicUrl;
|
try {
|
||||||
|
return new URL(publicUrl).toString();
|
||||||
|
} catch {
|
||||||
|
return new URL(publicUrl, getUrlObject(req)).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return getUrlObject(req).toString();
|
return getUrlObject(req).toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe('Styles', function () {
|
||||||
expect(res.body.sources).to.be.a('object');
|
expect(res.body.sources).to.be.a('object');
|
||||||
expect(res.body.glyphs).to.be.a('string');
|
expect(res.body.glyphs).to.be.a('string');
|
||||||
expect(res.body.sprite).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');
|
expect(res.body.layers).to.be.a('array');
|
||||||
})
|
})
|
||||||
.end(done);
|
.end(done);
|
||||||
|
|
Loading…
Reference in a new issue