tileserver-gl-light 4.4.3 → 4.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,7 +60,7 @@ jobs:
60
60
  uses: docker/setup-buildx-action@v2
61
61
 
62
62
  - name: Test Docker Build
63
- uses: docker/build-push-action@v3
63
+ uses: docker/build-push-action@v4
64
64
  with:
65
65
  context: .
66
66
  push: false
@@ -80,7 +80,7 @@ jobs:
80
80
  password: ${{ github.event.inputs.docker_token }}
81
81
 
82
82
  - name: Build and publish Full Version to Docker Hub
83
- uses: docker/build-push-action@v3
83
+ uses: docker/build-push-action@v4
84
84
  with:
85
85
  context: .
86
86
  push: true
@@ -106,7 +106,7 @@ jobs:
106
106
  NPM_TOKEN: ${{ github.event.inputs.npm_token }}
107
107
 
108
108
  - name: Build and publish Light Version to Docker Hub
109
- uses: docker/build-push-action@v3
109
+ uses: docker/build-push-action@v4
110
110
  with:
111
111
  context: ./light
112
112
  file: ./light/Dockerfile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tileserver-gl-light",
3
- "version": "4.4.3",
3
+ "version": "4.4.4",
4
4
  "description": "Map tile server for JSON GL styles - serving vector tiles",
5
5
  "main": "src/main.js",
6
6
  "bin": "src/main.js",
package/src/utils.js CHANGED
@@ -6,19 +6,35 @@ import fs from 'node:fs';
6
6
  import clone from 'clone';
7
7
  import glyphCompose from '@mapbox/glyph-pbf-composite';
8
8
 
9
- export const getPublicUrl = (publicUrl, req) =>
10
- publicUrl || `${req.protocol}://${req.headers.host}/`;
9
+ /**
10
+ * Generate new URL object
11
+ * @params {object} req - Express request
12
+ * @returns {URL} object
13
+ **/
14
+ const getUrlObject = (req) => {
15
+ const urlObject = new URL(`${req.protocol}://${req.headers.host}/`);
16
+ // support overriding hostname by sending X-Forwarded-Host http header
17
+ urlObject.hostname = req.hostname;
18
+ return urlObject;
19
+ };
20
+
21
+ export const getPublicUrl = (publicUrl, req) => {
22
+ if (publicUrl) {
23
+ return publicUrl;
24
+ }
25
+ return getUrlObject(req).toString();
26
+ };
11
27
 
12
28
  export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
29
+ const urlObject = getUrlObject(req);
13
30
  if (domains) {
14
31
  if (domains.constructor === String && domains.length > 0) {
15
32
  domains = domains.split(',');
16
33
  }
17
- const host = req.headers.host;
18
- const hostParts = host.split('.');
34
+ const hostParts = urlObject.host.split('.');
19
35
  const relativeSubdomainsUsable =
20
36
  hostParts.length > 1 &&
21
- !/^([0-9]{1,3}\.){3}[0-9]{1,3}(\:[0-9]+)?$/.test(host);
37
+ !/^([0-9]{1,3}\.){3}[0-9]{1,3}(\:[0-9]+)?$/.test(urlObject.host);
22
38
  const newDomains = [];
23
39
  for (const domain of domains) {
24
40
  if (domain.indexOf('*') !== -1) {
@@ -34,7 +50,7 @@ export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
34
50
  domains = newDomains;
35
51
  }
36
52
  if (!domains || domains.length == 0) {
37
- domains = [req.headers.host];
53
+ domains = [urlObject.host];
38
54
  }
39
55
 
40
56
  const queryParams = [];