bruce-models 4.5.9 → 4.6.0

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.
@@ -1046,9 +1046,6 @@
1046
1046
  * @param params
1047
1047
  */
1048
1048
  ConstructUrl(params) {
1049
- if (!(params === null || params === void 0 ? void 0 : params.url)) {
1050
- return null;
1051
- }
1052
1049
  if ((params === null || params === void 0 ? void 0 : params.cdn) && this.cdnBaseUrl) {
1053
1050
  return this.ConstructCdnUrl(params.url, params.urlParams);
1054
1051
  }
@@ -1070,12 +1067,24 @@
1070
1067
  tmp.pathname += "/";
1071
1068
  }
1072
1069
  if (params === null || params === void 0 ? void 0 : params.url) {
1070
+ // Ensure we're only adding the path.
1071
+ // The baseUrl could have included query params so have this extra logic.
1072
+ const split = params.url.split("?");
1073
1073
  // Ensure the url does not start with a slash.
1074
1074
  // This is because the base url already has a slash at the end.
1075
- if (params.url.startsWith("/")) {
1076
- params.url = params.url.substring(1);
1075
+ let path = split[0];
1076
+ if (path.startsWith("/")) {
1077
+ path = path.substring(1);
1078
+ }
1079
+ tmp.pathname += path;
1080
+ // Append the query string if any exist.
1081
+ if (split.length > 1) {
1082
+ const query = split[1].split("&");
1083
+ for (let q of query) {
1084
+ const parts = q.split("=");
1085
+ tmp.searchParams.append(parts[0], parts[1]);
1086
+ }
1077
1087
  }
1078
- tmp.pathname += params.url;
1079
1088
  }
1080
1089
  return tmp.toString();
1081
1090
  }
@@ -1108,12 +1117,24 @@
1108
1117
  tmp.pathname += "/";
1109
1118
  }
1110
1119
  if (url) {
1120
+ // Ensure we're only adding the path.
1121
+ // The baseUrl could have included query params so have this extra logic.
1122
+ let split = url.split("?");
1111
1123
  // Ensure the url does not start with a slash.
1112
1124
  // This is because the base url already has a slash at the end.
1113
- if (url.startsWith("/")) {
1114
- url = url.substring(1);
1125
+ let path = split[0];
1126
+ if (path.startsWith("/")) {
1127
+ path = url.substring(1);
1128
+ }
1129
+ tmp.pathname += path;
1130
+ // Append the query string if any exist.
1131
+ if (split.length > 1) {
1132
+ const query = split[1].split("&");
1133
+ for (let q of query) {
1134
+ const parts = q.split("=");
1135
+ tmp.searchParams.append(parts[0], parts[1]);
1136
+ }
1115
1137
  }
1116
- tmp.pathname += url;
1117
1138
  }
1118
1139
  return tmp.toString();
1119
1140
  }
@@ -1125,8 +1146,14 @@
1125
1146
  */
1126
1147
  SetBaseUrl(url) {
1127
1148
  this.baseUrl = url;
1128
- if (!this.baseUrl.endsWith("/")) {
1129
- this.baseUrl += "/";
1149
+ // If we're setting a valid URL then we'll ensure it ends with a slash.
1150
+ if (this.baseUrl && (this.baseUrl.startsWith("http://") || this.baseUrl.startsWith("https://"))) {
1151
+ // Parsing into URL object to avoid adding a "/" after query params.
1152
+ const full = new URL(this.baseUrl);
1153
+ if (!full.pathname.endsWith("/")) {
1154
+ full.pathname += "/";
1155
+ }
1156
+ this.baseUrl = full.toString();
1130
1157
  }
1131
1158
  this.loadCancelled = true;
1132
1159
  }
@@ -13463,7 +13490,7 @@
13463
13490
  })(exports.DataSource || (exports.DataSource = {}));
13464
13491
 
13465
13492
  // This is updated with the package.json version on build.
13466
- const VERSION = "4.5.9";
13493
+ const VERSION = "4.6.0";
13467
13494
 
13468
13495
  exports.VERSION = VERSION;
13469
13496
  exports.AbstractApi = AbstractApi;