@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.
@@ -4,9 +4,5 @@ interface userInput {
4
4
  }
5
5
  declare function userInputToJson({ input }: {
6
6
  input: userInput;
7
- }): Promise<{
8
- message: string;
9
- success: boolean;
10
- data: any;
11
- }>;
7
+ }): Promise<any>;
12
8
  export default userInputToJson;
@@ -8723,16 +8723,12 @@ function request(_a) {
8723
8723
  return basePathMap.get(env);
8724
8724
  };
8725
8725
  isValidURL = function (url) {
8726
- var pattern = new RegExp("^(https?:\/\/)?" + // protocol
8727
- "((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|" + // domain name
8728
- "((\d{1,3}\.){3}\d{1,3}))" + // OR ip (v4) address
8729
- "(\:\d+)?(\/[-a-z\d%_.&#126;+]*)*" + // port and path
8730
- "(\?[;&a-z\d%_.&#126;+=-]*)?" + // query string
8731
- "(\#[-a-z\d_]*)?$", "i"); // fragment locator
8732
- return !!pattern.test(url);
8726
+ var regex = /^https?:\/\//;
8727
+ return regex.test(url);
8733
8728
  };
8734
8729
  prefix = getBasePath();
8735
8730
  requestUrl = isValidURL(input.url) ? input.url : "".concat(prefix).concat(input.url);
8731
+ console.log('requestUrl', requestUrl, isValidURL(input.url));
8736
8732
  fetchOption = {
8737
8733
  method: method,
8738
8734
  headers: {
@@ -8764,20 +8760,28 @@ function request(_a) {
8764
8760
 
8765
8761
  function userInputToJson(_a) {
8766
8762
  return __awaiter(this, arguments, void 0, function (_b) {
8767
- var res;
8763
+ var res, result;
8768
8764
  var input = _b.input;
8769
8765
  return __generator(this, function (_c) {
8770
8766
  switch (_c.label) {
8771
- case 0: return [4 /*yield*/, request({
8772
- input: {
8773
- url: "https://fc-typechat.ywwl.com/userInputToJson",
8774
- method: "GET",
8775
- params: input,
8776
- },
8777
- })];
8767
+ case 0:
8768
+ console.log("input", input);
8769
+ return [4 /*yield*/, request({
8770
+ input: {
8771
+ url: "https://fc-typechat.ywwl.com/userInputToJson",
8772
+ method: "GET",
8773
+ params: input,
8774
+ },
8775
+ })];
8778
8776
  case 1:
8779
8777
  res = _c.sent();
8780
- return [2 /*return*/, res];
8778
+ if (res.success) {
8779
+ result = res.data;
8780
+ return [2 /*return*/, result.success ? result.data : result];
8781
+ }
8782
+ else {
8783
+ return [2 /*return*/, res.success ? res.data : res];
8784
+ }
8781
8785
  }
8782
8786
  });
8783
8787
  });