@wsxjs/wsx-router 0.0.23 → 0.0.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wsxjs/wsx-router",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "WSX Router - Native History API-based routing for WSXJS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -18,8 +18,8 @@
18
18
  "!**/test"
19
19
  ],
20
20
  "dependencies": {
21
- "@wsxjs/wsx-core": "0.0.23",
22
- "@wsxjs/wsx-logger": "0.0.23"
21
+ "@wsxjs/wsx-core": "0.0.24",
22
+ "@wsxjs/wsx-logger": "0.0.24"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@typescript-eslint/eslint-plugin": "^8.37.0",
@@ -31,8 +31,8 @@
31
31
  "typescript": "^5.0.0",
32
32
  "vite": "^5.4.19",
33
33
  "vitest": "^2.1.8",
34
- "@wsxjs/eslint-plugin-wsx": "0.0.23",
35
- "@wsxjs/wsx-vite-plugin": "0.0.23"
34
+ "@wsxjs/wsx-vite-plugin": "0.0.24",
35
+ "@wsxjs/eslint-plugin-wsx": "0.0.24"
36
36
  },
37
37
  "keywords": [
38
38
  "wsx",
package/src/WsxRouter.wsx CHANGED
@@ -366,7 +366,19 @@ export default class WsxRouter extends LightComponent {
366
366
  return this.views.get(path)!;
367
367
  }
368
368
 
369
- // RFC 0032: 3. 参数匹配(使用预编译的正则表达式)
369
+ // RFC 0032: 3. 前缀匹配(用于嵌套路由,如 /docs/*)
370
+ for (const [route, view] of this.views) {
371
+ if (route.endsWith("/*")) {
372
+ const prefix = route.slice(0, -2);
373
+ if (path.startsWith(prefix)) {
374
+ this.matchCache.set(path, route);
375
+ logger.warn(`matchRoute: prefix match found, route: ${route}, path: ${path}`);
376
+ return view;
377
+ }
378
+ }
379
+ }
380
+
381
+ // RFC 0032: 4. 参数匹配(使用预编译的正则表达式)
370
382
  logger.warn(
371
383
  `matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`
372
384
  );
@@ -391,7 +403,7 @@ export default class WsxRouter extends LightComponent {
391
403
  }
392
404
  }
393
405
 
394
- // RFC 0032: 4. 通配符匹配
406
+ // RFC 0032: 5. 通配符匹配(完全通配符 *)
395
407
  const wildcardView = this.views.get("*") || null;
396
408
  if (wildcardView) {
397
409
  this.matchCache.set(path, "*");