@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@ywfe/fe-tools",
4
- "version": "1.2.1-beta.30",
4
+ "version": "1.2.1-beta.31",
5
5
  "description": "工具函数库",
6
6
  "main": "./lib/ywfe-tools.cjs",
7
7
  "module": "./lib/ywfe-tools.esm.js",
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
- var pattern = new RegExp(
22
- "^(https?:\/\/)?" + // protocol
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: {
@@ -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
- return res
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