@maiyunnet/kebab 7.5.0 → 7.6.0
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/text.d.ts +12 -1
- package/lib/text.js +13 -15
- package/package.json +1 -1
- package/sys/child.js +9 -3
- package/sys/master.js +1 -1
- package/www/example/ctr/test.d.ts +1 -1
- package/www/example/ctr/test.js +17 -7
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '7.
|
|
9
|
+
export const VER = '7.6.0';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/text.d.ts
CHANGED
|
@@ -95,9 +95,20 @@ export declare function isIdCardCN(idcard: string): boolean;
|
|
|
95
95
|
/**
|
|
96
96
|
* --- 将对象转换为 query string ---
|
|
97
97
|
* @param query 要转换的对象
|
|
98
|
-
* @param encode
|
|
98
|
+
* @param encode 是否转义,默认为 true
|
|
99
99
|
*/
|
|
100
100
|
export declare function queryStringify(query: Record<string, any>, encode?: boolean): string;
|
|
101
|
+
/**
|
|
102
|
+
* --- 将对象转换为 query string ---
|
|
103
|
+
* @param query 要转换的对象
|
|
104
|
+
* @param options 选项
|
|
105
|
+
*/
|
|
106
|
+
export declare function queryStringify(query: Record<string, any>, options: {
|
|
107
|
+
/** --- 等号分隔符,默认 = --- */
|
|
108
|
+
'equal'?: string;
|
|
109
|
+
/** --- 连字符分隔符,默认 & --- */
|
|
110
|
+
'hyphen'?: string;
|
|
111
|
+
}): string;
|
|
101
112
|
/**
|
|
102
113
|
* --- 将 query string 转换为对象 ---
|
|
103
114
|
* @param query 要转换的字符串
|
package/lib/text.js
CHANGED
|
@@ -336,26 +336,24 @@ export function isIdCardCN(idcard) {
|
|
|
336
336
|
// --- 比较校验码 ---
|
|
337
337
|
return verifyCode === verifyCodeList[Number(mod)];
|
|
338
338
|
}
|
|
339
|
-
/**
|
|
340
|
-
* --- 将对象转换为 query string ---
|
|
341
|
-
* @param query 要转换的对象
|
|
342
|
-
* @param encode 是否转义
|
|
343
|
-
*/
|
|
344
339
|
export function queryStringify(query, encode = true) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
340
|
+
let isEncode = true;
|
|
341
|
+
let equal = '=';
|
|
342
|
+
let hyphen = '&';
|
|
343
|
+
if (typeof encode === 'object') {
|
|
344
|
+
equal = encode.equal ?? '=';
|
|
345
|
+
hyphen = encode.hyphen ?? '&';
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
isEncode = encode;
|
|
352
349
|
}
|
|
353
350
|
return Object.entries(query).map(([k, v]) => {
|
|
351
|
+
const key = isEncode ? encodeURIComponent(k) : k;
|
|
354
352
|
if (Array.isArray(v)) {
|
|
355
|
-
return v.map(
|
|
353
|
+
return v.map(i => `${key}${equal}${isEncode ? encodeURIComponent(i) : i}`).join(hyphen);
|
|
356
354
|
}
|
|
357
|
-
return `${
|
|
358
|
-
}).join(
|
|
355
|
+
return `${key}${equal}${isEncode ? encodeURIComponent(v) : v}`;
|
|
356
|
+
}).join(hyphen);
|
|
359
357
|
}
|
|
360
358
|
/**
|
|
361
359
|
* --- 将 query string 转换为对象 ---
|
package/package.json
CHANGED
package/sys/child.js
CHANGED
|
@@ -107,7 +107,9 @@ async function run() {
|
|
|
107
107
|
const host = (req.headers[':authority'] ?? req.headers['host'] ?? '');
|
|
108
108
|
if (!host) {
|
|
109
109
|
lCore.writeHead(res, 403);
|
|
110
|
-
res.end('403 Forbidden')
|
|
110
|
+
res.end('403 Forbidden', () => {
|
|
111
|
+
req.socket.destroy();
|
|
112
|
+
});
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
115
|
wrapWithLinkCount(host + req.url, () => requestHandler(req, res, true), '[CHILD][http2][request]');
|
|
@@ -126,7 +128,9 @@ async function run() {
|
|
|
126
128
|
if (!host) {
|
|
127
129
|
res.setHeader('x-kebab-error', '0');
|
|
128
130
|
lCore.writeHead(res, 403);
|
|
129
|
-
res.end()
|
|
131
|
+
res.end('403 Forbidden', () => {
|
|
132
|
+
req.socket.destroy();
|
|
133
|
+
});
|
|
130
134
|
return;
|
|
131
135
|
}
|
|
132
136
|
wrapWithLinkCount(host + (req.url ?? ''), () => requestHandler(req, res, false), '[CHILD][http][request]');
|
|
@@ -188,7 +192,9 @@ async function requestHandler(req, res, https) {
|
|
|
188
192
|
if (!vhost) {
|
|
189
193
|
res.setHeader('x-kebab-error', '1');
|
|
190
194
|
lCore.writeHead(res, 403);
|
|
191
|
-
res.end()
|
|
195
|
+
res.end('403 Forbidden', () => {
|
|
196
|
+
req.socket.destroy();
|
|
197
|
+
});
|
|
192
198
|
return;
|
|
193
199
|
/*
|
|
194
200
|
const text = '<h1>Kebab: No permissions</h1>host: ' + (req.headers[':authority'] as string | undefined ?? req.headers['host'] ?? '') + '<br>url: ' + (lText.htmlescape(req.url ?? ''));
|
package/sys/master.js
CHANGED
|
@@ -238,7 +238,7 @@ function createRpcListener() {
|
|
|
238
238
|
// --- 特殊文件不能覆盖 ---
|
|
239
239
|
continue;
|
|
240
240
|
}
|
|
241
|
-
if (fname.endsWith('.js.map') || fname.endsWith('.ts') || fname.endsWith('.gitignore')) {
|
|
241
|
+
if (fname.endsWith('.js.map') || fname.endsWith('.ts') || fname.endsWith('.gitignore') || fname.endsWith('.DS_Store')) {
|
|
242
242
|
// --- 测试或开发文件不覆盖 ---
|
|
243
243
|
continue;
|
|
244
244
|
}
|
package/www/example/ctr/test.js
CHANGED
|
@@ -2874,7 +2874,7 @@ const rtn = cons.migration(rows, newTables);</pre>`);
|
|
|
2874
2874
|
echo.push(JSON.stringify(rtn));
|
|
2875
2875
|
return echo.join('') + '<br><br>' + this._getEnd();
|
|
2876
2876
|
}
|
|
2877
|
-
text() {
|
|
2877
|
+
async text() {
|
|
2878
2878
|
const echo = `<pre>json_encode(lText.parseUrl('HtTp://uSer:pAss@sUBDom.TopdOm23.CoM:29819/Adm@xw2Ksiz/dszas?Mdi=KdiMs1&a=JDd#hehHe'))</pre>
|
|
2879
2879
|
${lText.htmlescape(JSON.stringify(lText.parseUrl('HtTp://uSer:pAss@sUBDom.TopdOm23.CoM:29819/Adm@xw2Ksiz/dszas?Mdi=KdiMs1&a=JDd#hehHe')))}
|
|
2880
2880
|
<pre>json_encode(lText.parseUrl('HtTp://uSer@sUBDom.TopdOm23.CoM/Admx%20w2Ksiz/dszas'))</pre>
|
|
@@ -2940,19 +2940,29 @@ ${JSON.stringify(lText.isDomain('www.xxx.com.cn'))}
|
|
|
2940
2940
|
<pre>lText.isDomain('com');</pre>
|
|
2941
2941
|
${JSON.stringify(lText.isDomain('com'))}
|
|
2942
2942
|
<pre>lText.parseDomain('www.xxx.com.cn');</pre>
|
|
2943
|
-
${JSON.stringify(lText.parseDomain('www.xxx.com.cn'))}
|
|
2943
|
+
${JSON.stringify(await lText.parseDomain('www.xxx.com.cn'))}
|
|
2944
2944
|
<pre>lText.parseDomain('www.xxx.us');</pre>
|
|
2945
|
-
${JSON.stringify(lText.parseDomain('www.xxx.us'))}
|
|
2945
|
+
${JSON.stringify(await lText.parseDomain('www.xxx.us'))}
|
|
2946
2946
|
<pre>lText.parseDomain('xxx.co.jp');</pre>
|
|
2947
|
-
${JSON.stringify(lText.parseDomain('xxx.co.jp'))}
|
|
2947
|
+
${JSON.stringify(await lText.parseDomain('xxx.co.jp'))}
|
|
2948
2948
|
<pre>lText.parseDomain('js.cn');</pre>
|
|
2949
|
-
${JSON.stringify(lText.parseDomain('js.cn'))}
|
|
2949
|
+
${JSON.stringify(await lText.parseDomain('js.cn'))}
|
|
2950
2950
|
<pre>lText.parseDomain('xxx.cn');</pre>
|
|
2951
|
-
${JSON.stringify(lText.parseDomain('xxx.cn'))}
|
|
2951
|
+
${JSON.stringify(await lText.parseDomain('xxx.cn'))}
|
|
2952
2952
|
<pre>lText.parseJson('{"num":90071992547409993149,"num2":3242354,"num3":"16565","str":"abc","bool":false}');</pre>
|
|
2953
2953
|
${lText.stringifyJson(lText.parseJson('{"num":90071992547409993149,"num2":3242354,"num3":"16565","str":"abc","bool":false}'))}
|
|
2954
2954
|
<pre>lText.isIdCardCN('110101200007284901')</pre>
|
|
2955
|
-
${JSON.stringify(lText.isIdCardCN('110101200007284901'))}
|
|
2955
|
+
${JSON.stringify(lText.isIdCardCN('110101200007284901'))}
|
|
2956
|
+
<pre>lText.queryStringify({'a': 1, 'b': '2'});</pre>
|
|
2957
|
+
${lText.queryStringify({ 'a': 1, 'b': '2' })}
|
|
2958
|
+
<pre>lText.queryStringify({ 'a': 1, 'b': '2' }, false);</pre>
|
|
2959
|
+
${lText.queryStringify({ 'a': 1, 'b': '2' }, false)}
|
|
2960
|
+
<pre>lText.queryStringify({ 'a': 1, 'b': '2' }, { 'equal': ':', 'hyphen': '|' });</pre>
|
|
2961
|
+
${lText.queryStringify({ 'a': 1, 'b': '2' }, { 'equal': ':', 'hyphen': '|' })}
|
|
2962
|
+
<pre>lText.queryStringify({ 'a': [1, 2], 'b': '3' }, { 'equal': ':', 'hyphen': '|' });</pre>
|
|
2963
|
+
${lText.queryStringify({ 'a': [1, 2], 'b': '3' }, { 'equal': ':', 'hyphen': '|' })}
|
|
2964
|
+
<pre>lText.queryStringify({ 'a': [1, 2], 'b': '3' }, { 'equal': '', 'hyphen': '' });</pre>
|
|
2965
|
+
${lText.queryStringify({ 'a': [1, 2], 'b': '3' }, { 'equal': '', 'hyphen': '' })}`;
|
|
2956
2966
|
return echo + '<br><br>' + this._getEnd();
|
|
2957
2967
|
}
|
|
2958
2968
|
time() {
|