@bigbinary/neeto-commons-frontend 2.1.4 → 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
@@ -6,7 +6,6 @@ import { serializeKeysToSnakeCase, keysToCamelCase, matches, deepFreezeObject }
6
6
  import { resetAuthTokens } from '@bigbinary/neeto-commons-frontend/utils';
7
7
  import { Toastr } from '@bigbinary/neetoui';
8
8
  import { evolve, omit, values, mergeDeepLeft, curry, mergeAll, either, isEmpty, isNil } from 'ramda';
9
- import { HEADERS_KEYS } from 'constants/axios';
10
9
  import { initReactI18next } from 'react-i18next';
11
10
  import Logger from 'js-logger';
12
11
  import mixpanel from 'mixpanel-browser';
@@ -52,6 +51,12 @@ function _defineProperty(obj, key, value) {
52
51
  return obj;
53
52
  }
54
53
 
54
+ var HEADERS_KEYS = {
55
+ xCsrfToken: "X-CSRF-TOKEN",
56
+ contentType: "Content-Type",
57
+ accept: "Accept"
58
+ };
59
+
55
60
  var shouldNot = function shouldNot(skip) {
56
61
  return _typeof$1(skip) === "object" || !skip;
57
62
  };
@@ -158,6 +163,13 @@ var showErrorToastr = function showErrorToastr(error) {
158
163
  }
159
164
  return error;
160
165
  };
166
+ var getUrlPathName = function getUrlPathName(url) {
167
+ try {
168
+ return new URL(url).pathname;
169
+ } catch (_unused) {
170
+ return url;
171
+ }
172
+ };
161
173
  var handle404ErrorResponse = function handle404ErrorResponse(error) {
162
174
  var _error$config4, _error$response4;
163
175
  var _ref4 = (_error$config4 = error.config) !== null && _error$config4 !== void 0 ? _error$config4 : {},
@@ -167,11 +179,13 @@ var handle404ErrorResponse = function handle404ErrorResponse(error) {
167
179
  show403ErrorPage = _ref4$show403ErrorPag === void 0 ? true : _ref4$show403ErrorPag;
168
180
  var status = (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.status;
169
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;
170
184
  useErrorDisplayStore.setState({
171
185
  showErrorPage: true,
172
186
  statusCode: status,
173
- failedApiUrl: error.config.url,
174
- failedApiPath: new URL(error.config.url).pathname
187
+ failedApiUrl: fullUrl,
188
+ failedApiPath: getUrlPathName(fullUrl)
175
189
  });
176
190
  }
177
191
  return error;