@availity/mui-spaces 1.0.24 → 1.0.25

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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.0.25](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.24...@availity/mui-spaces@1.0.25) (2025-06-11)
6
+
5
7
  ## [1.0.24](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.23...@availity/mui-spaces@1.0.24) (2025-06-11)
6
8
 
7
9
  ## [1.0.23](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.22...@availity/mui-spaces@1.0.23) (2025-06-10)
package/dist/index.js CHANGED
@@ -791,9 +791,9 @@ var openLink = (space, params) => __async(void 0, null, function* () {
791
791
  const needsSpaceId = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) || essentialsDomainRegex.test(space.link.url);
792
792
  const urlWithParams = needsSpaceId ? updateUrl(space.link.url, "spaceId", spaceId) : space.link.url;
793
793
  let url = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
794
- if (!(0, import_resolve_url2.isAbsoluteUrl)(url) && essentialsDomainRegex.test(window.location.origin) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
795
- const appsDomain = window.location.origin.replace("essentials", "apps");
796
- url = `${appsDomain}${url}`;
794
+ if (!(0, import_resolve_url2.isAbsoluteUrl)(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
795
+ const referrer = new URL(document.referrer);
796
+ url = `${referrer.origin}${url}`;
797
797
  }
798
798
  const target = getTarget(space.link.target);
799
799
  window.open(url, target);
package/dist/index.mjs CHANGED
@@ -749,9 +749,9 @@ var openLink = (space, params) => __async(void 0, null, function* () {
749
749
  const needsSpaceId = !isAbsoluteUrl2(space.link.url) || essentialsDomainRegex.test(space.link.url);
750
750
  const urlWithParams = needsSpaceId ? updateUrl(space.link.url, "spaceId", spaceId) : space.link.url;
751
751
  let url = !isAbsoluteUrl2(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
752
- if (!isAbsoluteUrl2(url) && essentialsDomainRegex.test(window.location.origin) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
753
- const appsDomain = window.location.origin.replace("essentials", "apps");
754
- url = `${appsDomain}${url}`;
752
+ if (!isAbsoluteUrl2(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
753
+ const referrer = new URL(document.referrer);
754
+ url = `${referrer.origin}${url}`;
755
755
  }
756
756
  const target = getTarget(space.link.target);
757
757
  window.open(url, target);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-spaces",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "Availity MUI Spaces Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -20,9 +20,9 @@ export const openLink: OpenLink = async (space, params) => {
20
20
 
21
21
  let url = !isAbsoluteUrl(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
22
22
 
23
- if (!isAbsoluteUrl(url) && essentialsDomainRegex.test(window.location.origin) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
24
- const appsDomain = window.location.origin.replace("essentials", "apps");
25
- url = `${appsDomain}${url}`
23
+ if (!isAbsoluteUrl(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
24
+ const referrer = new URL(document.referrer);
25
+ url = `${referrer.origin}${url}`
26
26
  }
27
27
 
28
28
  const target = getTarget(space.link.target);
@@ -29,7 +29,7 @@ const buildSpacesLink = (space: Space, linkAttributes: Record<any, any>) => {
29
29
  );
30
30
  };
31
31
 
32
- const originalWindowLocation = window.location;
32
+ const originalDocumentReferrer = document.referrer;
33
33
 
34
34
  describe('useLink', () => {
35
35
  beforeAll(() => {
@@ -40,9 +40,9 @@ describe('useLink', () => {
40
40
  Object.defineProperty(window, 'open', { value: jest.fn() });
41
41
  });
42
42
  afterEach(() => {
43
- Object.defineProperty(window, 'location', {
43
+ Object.defineProperty(document, 'referrer', {
44
44
  writable: true,
45
- value: originalWindowLocation,
45
+ value: originalDocumentReferrer,
46
46
  });
47
47
  jest.clearAllMocks();
48
48
  cleanup();
@@ -287,9 +287,9 @@ describe('useLink', () => {
287
287
  });
288
288
  });
289
289
 
290
- it('should replace essentials with apps for onprem', async () => {
291
- Object.defineProperty(window, 'location', {
292
- value: new URL("https://test-essentials.availity.com"),
290
+ it('should build relative onprem path to full url - t14', async () => {
291
+ Object.defineProperty(document, 'referrer', {
292
+ value: new URL("https://t14-apps.availity.com"),
293
293
  });
294
294
 
295
295
  space.id = '11';
@@ -305,7 +305,30 @@ describe('useLink', () => {
305
305
  if (linkHeader11) fireEvent.click(linkHeader11);
306
306
 
307
307
  await waitFor(() => {
308
- expect(window.open).toHaveBeenCalledWith('https://test-apps.availity.com/public/spaces/url?spaceId=11', '_self');
308
+ expect(window.open).toHaveBeenCalledWith('https://t14-apps.availity.com/public/spaces/url?spaceId=11', '_self');
309
+ expect(nativeForm).not.toHaveBeenCalled();
310
+ });
311
+ });
312
+
313
+ it('should build relative onprem path to full url - test', async () => {
314
+ Object.defineProperty(document, 'referrer', {
315
+ value: new URL("https://test-apps.availity.com"),
316
+ });
317
+
318
+ space.id = '12';
319
+ space.configurationId = '12';
320
+ space.link = { text: 'the link', target: '_self', url: '/public/spaces/url' };
321
+ space.type = 'APPLICATION';
322
+ space.meta = {};
323
+
324
+ const { container } = render(buildSpacesLink(space, { spaceId: space.id }));
325
+
326
+ const linkHeader = await waitFor(() => container.querySelector('#app-title-12'));
327
+
328
+ if (linkHeader) fireEvent.click(linkHeader);
329
+
330
+ await waitFor(() => {
331
+ expect(window.open).toHaveBeenCalledWith('https://test-apps.availity.com/public/spaces/url?spaceId=12', '_self');
309
332
  expect(nativeForm).not.toHaveBeenCalled();
310
333
  });
311
334
  });