@trailstash/ultra 3.8.4 → 3.8.5

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.
package/.gitlab-ci.yml CHANGED
@@ -1,3 +1,8 @@
1
+ test:
2
+ image: node:20
3
+ script:
4
+ - npm ci
5
+ - npm test
1
6
  pages:
2
7
  image: node:20
3
8
  script:
@@ -14,14 +14,15 @@ const overpassQLRegexes = [
14
14
  /\({{bbox}}\)/,
15
15
  /\[out:json\]/,
16
16
  /\[out:xml\]/,
17
- /node\[[^]\]/,
18
- /way\[[^]\]/,
19
- /relation\[[^]\]/,
20
- /nwr\[[^]\]/,
21
- /nw\[[^]\]/,
22
- /nr\[[^]\]/,
23
- /wr\[[^]\]/,
24
- /area\[[^]\]/,
17
+ /node\[[^\]]+]/,
18
+ /way\[[^\]]+]/,
19
+ /relation\[[^\]]+]/,
20
+ /nwr\[[^\]]+]/,
21
+ /nw\[[^\]]+]/,
22
+ /nr\[[^\]]+]/,
23
+ /wr\[[^\]]+]/,
24
+ /area\[[^\]]+]/,
25
+
25
26
  /node\([^)]\)/,
26
27
  /way\([^)]\)/,
27
28
  /relation\([^)]\)/,
@@ -30,7 +31,8 @@ const overpassQLRegexes = [
30
31
  /nr\([^)]\)/,
31
32
  /wr\([^)]\)/,
32
33
  /area\([^)]\)/,
33
- /out( geom| center| skel)?;/,
34
+
35
+ /out( meta| geom| center| skel)*;/,
34
36
  ];
35
37
  function detect(query) {
36
38
  const doc = new window.DOMParser().parseFromString(query, "text/xml");
@@ -42,9 +44,10 @@ function detect(query) {
42
44
  }
43
45
  for (const re of overpassQLRegexes) {
44
46
  if (query.match(re)) {
45
- return query;
47
+ return true;
46
48
  }
47
49
  }
50
+ return false;
48
51
  }
49
52
 
50
53
  const overpass = {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import overpass from "./overpass.js";
6
+
7
+ describe("overpass", () => {
8
+ it("should detect Overpass XML", () => {
9
+ expect(overpass.detect("<osm-script></osm-script>")).toEqual(true);
10
+ });
11
+ it("should detect OverpassQL", () => {
12
+ expect(overpass.detect("node(8072127669);out;")).toEqual(true);
13
+ expect(
14
+ overpass.detect("node[amenity=bicycle_repair_station];out meta;"),
15
+ ).toEqual(true);
16
+ expect(
17
+ overpass.detect(
18
+ "[bbox:-85.05112899999985,-143.4237868840288,85.05112900000006,143.19307950688642];way[highway];out geom;",
19
+ ),
20
+ ).toEqual(true);
21
+ expect(
22
+ overpass.detect(`[bbox:-85.05112899999985,-143.4237868840288,85.05112900000006,143.19307950688642];
23
+ (
24
+ way[highway=path];
25
+ way[highway=footway];
26
+ way[highway=cycleway];
27
+ way[highway=steps];
28
+ );
29
+ out meta geom;`),
30
+ ).toEqual(true);
31
+ });
32
+ });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.8.4",
6
+ "version": "3.8.5",
7
7
  "description": "A web based tool for making MapLibre GL maps with data from sources such as Overpass, GeoJSON, GPX, KML, TCX, etc",
8
8
  "main": "index.js",
9
9
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "build:pages": "mkdir -p public && cp -Lr dist/* public/.",
18
18
  "start": "node ./bin/run.js serve",
19
19
  "format": "prettier --print-width=80 --write '**/*.js' '**/*.json' README.md '**/*.css'",
20
- "test": "echo \"Error: no test specified\" && exit 1"
20
+ "test": "jest"
21
21
  },
22
22
  "type": "module",
23
23
  "repository": {
@@ -44,6 +44,9 @@
44
44
  "devDependencies": {
45
45
  "@types/node": "^22.6.1",
46
46
  "@unvt/sprite-one": "^0.1.1",
47
+ "esbuild-jest": "^0.5.0",
48
+ "jest": "^29.7.0",
49
+ "jest-environment-jsdom": "^29.7.0",
47
50
  "prettier": "^3.3.3",
48
51
  "puppeteer": "^23.4.0",
49
52
  "svg2png": "^4.1.1",
@@ -83,5 +86,10 @@
83
86
  "commands": "./cli",
84
87
  "dirname": "ultra",
85
88
  "topicSeparator": " "
89
+ },
90
+ "jest": {
91
+ "transform": {
92
+ "^.+\\.js$": "esbuild-jest"
93
+ }
86
94
  }
87
95
  }