@ywfe/fe-tools 1.2.1-beta.30 → 1.2.1-beta.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -8721,13 +8721,8 @@ function request(_a) {
8721
8721
  return basePathMap.get(env);
8722
8722
  };
8723
8723
  isValidURL = function (url) {
8724
- var pattern = new RegExp("^(https?:\/\/)?" + // protocol
8725
- "((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|" + // domain name
8726
- "((\d{1,3}\.){3}\d{1,3}))" + // OR ip (v4) address
8727
- "(\:\d+)?(\/[-a-z\d%_.~+]*)*" + // port and path
8728
- "(\?[;&a-z\d%_.~+=-]*)?" + // query string
8729
- "(\#[-a-z\d_]*)?$", "i"); // fragment locator
8730
- return !!pattern.test(url);
8724
+ var regex = /^https?:\/\//;
8725
+ return regex.test(url);
8731
8726
  };
8732
8727
  prefix = getBasePath();
8733
8728
  requestUrl = isValidURL(input.url) ? input.url : "".concat(prefix).concat(input.url);
@@ -8749,11 +8744,13 @@ function request(_a) {
8749
8744
  response = _c.sent();
8750
8745
  if (!response.ok) {
8751
8746
  message = "An error has occured: ".concat(response.status);
8747
+ console.log('req result', message);
8752
8748
  return [2 /*return*/, { success: false, message: message }];
8753
8749
  }
8754
8750
  return [4 /*yield*/, response.json()];
8755
8751
  case 2:
8756
8752
  result = _c.sent();
8753
+ console.log('req result', result);
8757
8754
  return [2 /*return*/, result];
8758
8755
  }
8759
8756
  });
@@ -8762,20 +8759,28 @@ function request(_a) {
8762
8759
 
8763
8760
  function userInputToJson(_a) {
8764
8761
  return __awaiter(this, arguments, void 0, function (_b) {
8765
- var res;
8762
+ var res, result;
8766
8763
  var input = _b.input;
8767
8764
  return __generator(this, function (_c) {
8768
8765
  switch (_c.label) {
8769
- case 0: return [4 /*yield*/, request({
8770
- input: {
8771
- url: "https://fc-typechat.ywwl.com/userInputToJson",
8772
- method: "GET",
8773
- params: input,
8774
- },
8775
- })];
8766
+ case 0:
8767
+ console.log("input", input);
8768
+ return [4 /*yield*/, request({
8769
+ input: {
8770
+ url: "https://fc-typechat.ywwl.com/userInputToJson",
8771
+ method: "GET",
8772
+ params: input,
8773
+ },
8774
+ })];
8776
8775
  case 1:
8777
8776
  res = _c.sent();
8778
- return [2 /*return*/, res];
8777
+ if (res.success) {
8778
+ result = res.data;
8779
+ return [2 /*return*/, result.success ? result.data : result];
8780
+ }
8781
+ else {
8782
+ return [2 /*return*/, res.success ? res.data : res];
8783
+ }
8779
8784
  }
8780
8785
  });
8781
8786
  });