feat: allow multiple urls with same filename
Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
d0ba661ad0
commit
c64c07790d
3 changed files with 21 additions and 3 deletions
12
package-lock.json
generated
12
package-lock.json
generated
|
|
@ -16,6 +16,7 @@
|
|||
"@mapbox/vector-tile": "1.3.1",
|
||||
"@maplibre/maplibre-gl-native": "5.2.0",
|
||||
"@maplibre/maplibre-gl-style-spec": "18.0.0",
|
||||
"@sindresorhus/fnv1a": "3.0.0",
|
||||
"advanced-pool": "0.3.3",
|
||||
"canvas": "2.11.2",
|
||||
"chokidar": "3.5.3",
|
||||
|
|
@ -986,6 +987,17 @@
|
|||
"@octokit/openapi-types": "^12.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sindresorhus/fnv1a": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/fnv1a/-/fnv1a-3.0.0.tgz",
|
||||
"integrity": "sha512-M6pmbdZqAryzjZ4ELAzrdCMoMZk5lH/fshKrapfSeXdf2W+GDqZvPmfXaNTZp43//FVbSwkTPwpEMnehSyskkQ==",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@tootallnate/once": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
"@mapbox/vector-tile": "1.3.1",
|
||||
"@maplibre/maplibre-gl-native": "5.2.0",
|
||||
"@maplibre/maplibre-gl-style-spec": "18.0.0",
|
||||
"@sindresorhus/fnv1a": "3.0.0",
|
||||
"advanced-pool": "0.3.3",
|
||||
"canvas": "2.11.2",
|
||||
"chokidar": "3.5.3",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ process.env.UV_THREADPOOL_SIZE = Math.ceil(Math.max(4, os.cpus().length * 1.5));
|
|||
|
||||
import fs from 'node:fs';
|
||||
import path from 'path';
|
||||
|
||||
import fnv1a from '@sindresorhus/fnv1a';
|
||||
import chokidar from 'chokidar';
|
||||
import clone from 'clone';
|
||||
import cors from 'cors';
|
||||
|
|
@ -207,8 +207,13 @@ function start(opts) {
|
|||
);
|
||||
return undefined;
|
||||
} else {
|
||||
let id = StyleSourceId.replace(/^.*\/(.*)$/, '$1'); // Remove url path up to last backslash, if it exists
|
||||
id = id.substr(0, StyleSourceId.lastIndexOf('.')) || id; // Remove extension, if it exists
|
||||
let id =
|
||||
StyleSourceId.substr(0, StyleSourceId.lastIndexOf('.')) ||
|
||||
StyleSourceId;
|
||||
if (isValidHttpUrl(StyleSourceId)) {
|
||||
id =
|
||||
id.replace(/^.*\/(.*)$/, '$1') + '_' + fnv1a(StyleSourceId);
|
||||
}
|
||||
while (data[id]) id += '_'; //if the data source id already exists, add a "_" untill it doesn't
|
||||
//Add the new data source to the data array.
|
||||
data[id] = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue