mm_statics 1.7.1 → 1.7.2

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.
Files changed (2) hide show
  1. package/index.js +15 -2
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -608,6 +608,15 @@ Static.prototype._handleCache = async function (url, ctx) {
608
608
  return false;
609
609
  };
610
610
 
611
+ /**
612
+ * 将路由路径转换为物理路径
613
+ * @param {string} path 文件路径
614
+ * @returns {string} 根路径
615
+ */
616
+ Static.prototype.pathToRoot = function (path) {
617
+ return path.replace(this.config.path, "/");
618
+ }
619
+
611
620
  /**
612
621
  * 处理文件编译逻辑
613
622
  * @param {string} path 文件路径
@@ -659,13 +668,17 @@ Static.prototype._handleCompiledResp = async function (url, path, body, ctx) {
659
668
  */
660
669
  Static.prototype.main = async function (ctx, next) {
661
670
  const url = ctx.url; // 使用完整URL(包含查询参数)
662
- const path = ctx.path; // 仅用于文件路径检查
663
-
671
+ if (!url.startsWith(this.config.path)) {
672
+ await next();
673
+ return;
674
+ }
664
675
  // 检查缓存
665
676
  if (await this._handleCache(url, ctx)) {
666
677
  return;
667
678
  }
668
679
 
680
+ const path = this.pathToRoot(ctx.path);
681
+
669
682
  // 处理文件编译
670
683
  let body = await this._handleFileCompile(path);
671
684
  if (body) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_statics",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "这是超级美眉statics函数模块,用于web服务端statics缓存",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -49,8 +49,8 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "eslint": "^9.39.2",
52
- "eslint-plugin-jsdoc": "^62.4.1",
53
- "mm_eslint": "^1.5.7",
52
+ "eslint-plugin-jsdoc": "^62.5.0",
53
+ "mm_eslint": "^1.6.3",
54
54
  "mocha": "^11.7.5",
55
55
  "supertest": "^7.2.2"
56
56
  }