@stemy/ngx-utils 13.6.0 → 13.6.3

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.
@@ -13,7 +13,7 @@ import * as i1 from 'ngx-device-detector';
13
13
  import { DeviceDetectorService } from 'ngx-device-detector';
14
14
  import * as i1$1 from '@angular/common/http';
15
15
  import { HttpClient, HttpHeaders, HttpParams, HttpUrlEncodingCodec, HttpEventType } from '@angular/common/http';
16
- import * as JSON5 from 'json5';
16
+ import JSON5 from 'json5';
17
17
  import * as i1$2 from '@angular/platform-browser';
18
18
  import { ɵDomEventsPlugin, EVENT_MANAGER_PLUGINS } from '@angular/platform-browser';
19
19
  import elementResizeDetectorMaker from 'element-resize-detector';
@@ -5593,7 +5593,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
5593
5593
  function loadBaseUrl() {
5594
5594
  if (typeof (document) === "undefined" || typeof (location) === "undefined")
5595
5595
  return "/";
5596
+ const scripts = Array.from(document.scripts);
5596
5597
  const currentScript = document.currentScript;
5598
+ let currentUrl = new URL(currentScript?.src ?? "http://localhost:4200/");
5597
5599
  if (!currentScript) {
5598
5600
  try {
5599
5601
  // noinspection ExceptionCaughtLocallyJS
@@ -5603,13 +5605,19 @@ function loadBaseUrl() {
5603
5605
  const qualifiedUrl = location.protocol + "//" + location.host;
5604
5606
  const stack = (e.stack || "");
5605
5607
  const srcUrl = (stack.match(new RegExp(qualifiedUrl + ".*?\\.js", "g")) || stack.match(/http([A-Z:\/\-.]+)\.js/gi)).shift();
5606
- const lastIndex = srcUrl.lastIndexOf("/");
5607
- return lastIndex < 0 ? "/" : srcUrl.substring(0, lastIndex + 1);
5608
+ currentUrl = new URL(srcUrl ?? "");
5608
5609
  }
5609
5610
  }
5610
- const scriptSrc = currentScript.src;
5611
- const lastIndex = scriptSrc.lastIndexOf("/");
5612
- return lastIndex < 0 ? "/" : scriptSrc.substring(0, lastIndex + 1);
5611
+ const mainScript = scripts.find(s => {
5612
+ if (!s.src)
5613
+ return false;
5614
+ const sUrl = new URL(s.src);
5615
+ return currentUrl.host === sUrl.host && sUrl.pathname.includes("main");
5616
+ });
5617
+ const scriptUrl = !mainScript ? currentUrl : new URL(mainScript.src);
5618
+ const path = scriptUrl.pathname?.split("/") ?? [];
5619
+ path.pop();
5620
+ return `${scriptUrl.protocol}//${scriptUrl.host}${path.join("/")}/`;
5613
5621
  }
5614
5622
  function loadBaseHref(baseUrl) {
5615
5623
  try {