whistle.mock-plugins 1.1.3-beta.2 → 1.1.3-dev.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.
|
@@ -73,8 +73,6 @@
|
|
|
73
73
|
|
|
74
74
|
/** */
|
|
75
75
|
|
|
76
|
-
/** */
|
|
77
|
-
|
|
78
76
|
/** */
|
|
79
77
|
|
|
80
78
|
/** */
|
|
@@ -93,8 +91,6 @@
|
|
|
93
91
|
|
|
94
92
|
/** */
|
|
95
93
|
|
|
96
|
-
/** */
|
|
97
|
-
|
|
98
94
|
/** */
|
|
99
95
|
|
|
100
96
|
/** */
|
|
@@ -129,6 +125,8 @@
|
|
|
129
125
|
|
|
130
126
|
/** */
|
|
131
127
|
|
|
128
|
+
/** */
|
|
129
|
+
|
|
132
130
|
/** */
|
|
133
131
|
|
|
134
132
|
/** */
|
package/lib/ui-server.js
CHANGED
|
@@ -38,7 +38,25 @@ app.all('/cgi-bin/*', function(req, res) {
|
|
|
38
38
|
res.setHeader('Access-Control-Allow-Credentials', true);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
// 原始URL路径
|
|
42
|
+
let urlPath = req.url.replace(/\?.*$/, '');
|
|
43
|
+
let controller = CGI_MODULES[APP_ROOT + urlPath];
|
|
44
|
+
|
|
45
|
+
// 如果直接匹配失败,尝试匹配带路径参数的路由
|
|
46
|
+
if (!controller) {
|
|
47
|
+
// 检查是否是接口相关的路由(带ID参数)
|
|
48
|
+
const interfacesMatch = urlPath.match(/^\/cgi-bin\/interfaces(\/[^\/]+)?$/);
|
|
49
|
+
if (interfacesMatch) {
|
|
50
|
+
controller = CGI_MODULES[APP_ROOT + '/cgi-bin/interfaces'];
|
|
51
|
+
// 将路径参数添加到请求对象中
|
|
52
|
+
if (interfacesMatch[1]) {
|
|
53
|
+
const id = interfacesMatch[1].substring(1); // 移除前面的'/'
|
|
54
|
+
req.params = req.params || {};
|
|
55
|
+
req.params.id = id;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
42
60
|
if (!controller) {
|
|
43
61
|
res.status(404).end('Not found');
|
|
44
62
|
return;
|