ddan-js 2.9.3 → 2.9.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.
- package/bin/ddan-js.browser.js +1 -1
- package/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/modules/fetch.js +1 -1
- package/bin/lib/modules/qs/index.js +47 -9
- package/bin/types/browser.d.ts +2 -2
- package/bin/types/index.d.ts +2 -2
- package/bin/types/modules/fetch.d.ts +1 -1
- package/package.json +1 -1
|
@@ -34,20 +34,58 @@ const parsePath = (url) => {
|
|
|
34
34
|
const route = _url.substring(0, idx) || '';
|
|
35
35
|
return { route, page, name, withoutExtension, extname };
|
|
36
36
|
};
|
|
37
|
+
// const join = (...args: string[]) => {
|
|
38
|
+
// let arr: string[] = []
|
|
39
|
+
// args.forEach((e) => {
|
|
40
|
+
// const _s = e.trim().replace(/^\/*(.*?)\/*$/, '$1')
|
|
41
|
+
// if (_s.length <= 0) return
|
|
42
|
+
// if (/^(\w+):\/\//.test(_s)) {
|
|
43
|
+
// arr = [_s]
|
|
44
|
+
// } else {
|
|
45
|
+
// arr.push(_s)
|
|
46
|
+
// }
|
|
47
|
+
// })
|
|
48
|
+
// return arr.join('/')
|
|
49
|
+
// }
|
|
37
50
|
const join = (...args) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
const result = [];
|
|
52
|
+
let hasProtocol = false;
|
|
53
|
+
args.forEach((part) => {
|
|
54
|
+
const trimmed = part.trim();
|
|
55
|
+
if (trimmed === '') {
|
|
56
|
+
// 忽略空段
|
|
42
57
|
return;
|
|
43
|
-
if (/^(\w+):\/\//.test(_s)) {
|
|
44
|
-
arr = [_s];
|
|
45
58
|
}
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
if (/^(\w+):\/\//.test(trimmed)) {
|
|
60
|
+
// 处理带协议的路径,重置所有内容
|
|
61
|
+
result.length = 0;
|
|
62
|
+
result.push(trimmed);
|
|
63
|
+
hasProtocol = true;
|
|
64
|
+
return;
|
|
48
65
|
}
|
|
66
|
+
const segments = trimmed.split('/');
|
|
67
|
+
segments.forEach((segment) => {
|
|
68
|
+
if (segment === '.' || segment === '') {
|
|
69
|
+
// 忽略当前目录标志或多余的斜杠
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (segment === '..') {
|
|
73
|
+
// 返回上一级目录
|
|
74
|
+
if (result.length > 0 && result[result.length - 1] !== '..') {
|
|
75
|
+
result.pop();
|
|
76
|
+
}
|
|
77
|
+
else if (!hasProtocol) {
|
|
78
|
+
// 非协议情况下,保留多余的 ".."
|
|
79
|
+
result.push('..');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// 普通路径段,直接加入
|
|
84
|
+
result.push(segment);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
49
87
|
});
|
|
50
|
-
return
|
|
88
|
+
return result.join('/');
|
|
51
89
|
};
|
|
52
90
|
const parseHost = (url) => {
|
|
53
91
|
const result = {
|
package/bin/types/browser.d.ts
CHANGED
|
@@ -562,7 +562,7 @@ declare const dWeb: {
|
|
|
562
562
|
fail?: ((error: Error) => void) | undefined;
|
|
563
563
|
}) => Promise<Uint8Array | undefined>;
|
|
564
564
|
getText: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, string]>;
|
|
565
|
-
cache: (url: string, cache?: RequestCache
|
|
565
|
+
cache: (url: string, cache?: RequestCache) => Promise<[any, undefined] | [null, boolean]>;
|
|
566
566
|
};
|
|
567
567
|
Http: typeof Http;
|
|
568
568
|
css: {
|
|
@@ -1077,7 +1077,7 @@ declare const _default: {
|
|
|
1077
1077
|
fail?: ((error: Error) => void) | undefined;
|
|
1078
1078
|
}) => Promise<Uint8Array | undefined>;
|
|
1079
1079
|
getText: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, string]>;
|
|
1080
|
-
cache: (url: string, cache?: RequestCache
|
|
1080
|
+
cache: (url: string, cache?: RequestCache) => Promise<[any, undefined] | [null, boolean]>;
|
|
1081
1081
|
};
|
|
1082
1082
|
rsa: {
|
|
1083
1083
|
generateKeys: () => Promise<{
|
package/bin/types/index.d.ts
CHANGED
|
@@ -562,7 +562,7 @@ declare const dWeb: {
|
|
|
562
562
|
fail?: ((error: Error) => void) | undefined;
|
|
563
563
|
}) => Promise<Uint8Array | undefined>;
|
|
564
564
|
getText: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, string]>;
|
|
565
|
-
cache: (url: string, cache?: RequestCache
|
|
565
|
+
cache: (url: string, cache?: RequestCache) => Promise<[any, undefined] | [null, boolean]>;
|
|
566
566
|
};
|
|
567
567
|
Http: typeof Http;
|
|
568
568
|
css: {
|
|
@@ -1113,7 +1113,7 @@ declare const _default: {
|
|
|
1113
1113
|
fail?: ((error: Error) => void) | undefined;
|
|
1114
1114
|
}) => Promise<Uint8Array | undefined>;
|
|
1115
1115
|
getText: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, string]>;
|
|
1116
|
-
cache: (url: string, cache?: RequestCache
|
|
1116
|
+
cache: (url: string, cache?: RequestCache) => Promise<[any, undefined] | [null, boolean]>;
|
|
1117
1117
|
};
|
|
1118
1118
|
rsa: {
|
|
1119
1119
|
generateKeys: () => Promise<{
|
|
@@ -11,6 +11,6 @@ declare const _default: {
|
|
|
11
11
|
fail?: ((error: Error) => void) | undefined;
|
|
12
12
|
}) => Promise<Uint8Array | undefined>;
|
|
13
13
|
getText: (url: string, cache?: RequestCache | undefined) => Promise<[any, undefined] | [null, string]>;
|
|
14
|
-
cache: (url: string, cache?: RequestCache
|
|
14
|
+
cache: (url: string, cache?: RequestCache) => Promise<[any, undefined] | [null, boolean]>;
|
|
15
15
|
};
|
|
16
16
|
export default _default;
|