fix: improve getUrlObject
Signed-off-by: Manuel Roth <manuelroth@hotmail.ch>
This commit is contained in:
parent
fc21a43a4d
commit
49f7b99321
1 changed files with 4 additions and 4 deletions
|
|
@ -6,8 +6,8 @@ import fs from 'node:fs';
|
||||||
import clone from 'clone';
|
import clone from 'clone';
|
||||||
import glyphCompose from '@mapbox/glyph-pbf-composite';
|
import glyphCompose from '@mapbox/glyph-pbf-composite';
|
||||||
|
|
||||||
const getUrlObject = (urlString, req) => {
|
const getUrlObject = (req) => {
|
||||||
const urlObject = new URL(urlString);
|
const urlObject = new URL(`${req.protocol}://${req.headers.host}/`);
|
||||||
// support overriding hostname by sending X-Forwarded-Host http header
|
// support overriding hostname by sending X-Forwarded-Host http header
|
||||||
urlObject.hostname = req.hostname;
|
urlObject.hostname = req.hostname;
|
||||||
|
|
||||||
|
|
@ -19,12 +19,12 @@ export const getPublicUrl = (publicUrl, req) => {
|
||||||
return publicUrl;
|
return publicUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const urlObject = getUrlObject(`${req.protocol}://${req.headers.host}/`, req);
|
const urlObject = getUrlObject(req);
|
||||||
return urlObject.toString();
|
return urlObject.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
|
export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
|
||||||
const urlObject = getUrlObject(`${req.protocol}://${req.headers.host}/`, req);
|
const urlObject = getUrlObject(req);
|
||||||
const host = urlObject.host;
|
const host = urlObject.host;
|
||||||
|
|
||||||
if (domains) {
|
if (domains) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue