@bigbinary/neeto-commons-frontend 2.1.5 → 2.1.6

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.
package/initializers.js CHANGED
@@ -163,6 +163,13 @@ var showErrorToastr = function showErrorToastr(error) {
163
163
  }
164
164
  return error;
165
165
  };
166
+ var getUrlPathName = function getUrlPathName(url) {
167
+ try {
168
+ return new URL(url).pathname;
169
+ } catch (_unused) {
170
+ return url;
171
+ }
172
+ };
166
173
  var handle404ErrorResponse = function handle404ErrorResponse(error) {
167
174
  var _error$config4, _error$response4;
168
175
  var _ref4 = (_error$config4 = error.config) !== null && _error$config4 !== void 0 ? _error$config4 : {},
@@ -172,11 +179,13 @@ var handle404ErrorResponse = function handle404ErrorResponse(error) {
172
179
  show403ErrorPage = _ref4$show403ErrorPag === void 0 ? true : _ref4$show403ErrorPag;
173
180
  var status = (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.status;
174
181
  if (status === 404 && show404ErrorPage || status === 403 && show403ErrorPage) {
182
+ var _error$request;
183
+ var fullUrl = ((_error$request = error.request) === null || _error$request === void 0 ? void 0 : _error$request.responseURL) || error.config.url;
175
184
  useErrorDisplayStore.setState({
176
185
  showErrorPage: true,
177
186
  statusCode: status,
178
- failedApiUrl: error.config.url,
179
- failedApiPath: new URL(error.config.url).pathname
187
+ failedApiUrl: fullUrl,
188
+ failedApiPath: getUrlPathName(fullUrl)
180
189
  });
181
190
  }
182
191
  return error;