@ywfe/fe-tools 1.2.1-beta.30 → 1.2.1-beta.31
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/userInputToJson.d.ts +1 -5
- package/lib/ywfe-tools.cjs +20 -16
- package/lib/ywfe-tools.cjs.map +1 -1
- package/lib/ywfe-tools.esm.js +20 -16
- package/lib/ywfe-tools.esm.js.map +1 -1
- package/lib/ywfe-tools.umd.js +2 -2
- package/lib/ywfe-tools.umd.js.map +1 -1
- package/package.json +1 -1
- package/request.ts +3 -10
- package/userInputToJson.ts +7 -2
package/package.json
CHANGED
package/request.ts
CHANGED
@@ -18,19 +18,12 @@ async function request({ input }: { input: RequestOptions }) {
|
|
18
18
|
return basePathMap.get(env);
|
19
19
|
};
|
20
20
|
const isValidURL = (url:string) => {
|
21
|
-
|
22
|
-
|
23
|
-
"((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|" + // domain name
|
24
|
-
"((\d{1,3}\.){3}\d{1,3}))" + // OR ip (v4) address
|
25
|
-
"(\:\d+)?(\/[-a-z\d%_.~+]*)*" + // port and path
|
26
|
-
"(\?[;&a-z\d%_.~+=-]*)?" + // query string
|
27
|
-
"(\#[-a-z\d_]*)?$",
|
28
|
-
"i"
|
29
|
-
); // fragment locator
|
30
|
-
return !!pattern.test(url);
|
21
|
+
const regex = /^https?:\/\//;
|
22
|
+
return regex.test(url);
|
31
23
|
};
|
32
24
|
const prefix = getBasePath();
|
33
25
|
let requestUrl = isValidURL(input.url) ? input.url : `${prefix}${input.url}`;
|
26
|
+
console.log('requestUrl',requestUrl,isValidURL(input.url))
|
34
27
|
const fetchOption: { [key: string]: any } = {
|
35
28
|
method: method,
|
36
29
|
headers: {
|
package/userInputToJson.ts
CHANGED
@@ -5,6 +5,7 @@ interface userInput {
|
|
5
5
|
rules?: string;
|
6
6
|
}
|
7
7
|
async function userInputToJson({ input }: { input: userInput }) {
|
8
|
+
console.log("input", input);
|
8
9
|
const res: { message: string; success: boolean; data: any } =
|
9
10
|
await request({
|
10
11
|
input: {
|
@@ -13,7 +14,11 @@ async function userInputToJson({ input }: { input: userInput }) {
|
|
13
14
|
params: input,
|
14
15
|
},
|
15
16
|
});
|
16
|
-
|
17
|
-
|
17
|
+
if (res.success) {
|
18
|
+
const result = res.data;
|
19
|
+
return result.success ? result.data : result;
|
20
|
+
} else {
|
21
|
+
return res.success ? res.data : res;
|
22
|
+
}
|
18
23
|
}
|
19
24
|
export default userInputToJson
|