stormcloud-video-player 0.8.33 → 0.8.34

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.
@@ -1562,6 +1562,41 @@ function createHlsAdPlayer(contentVideo, options) {
1562
1562
  }
1563
1563
  };
1564
1564
  }
1565
+ // src/utils/devUrl.ts
1566
+ var PRIVATE_HOST_PATTERNS = [
1567
+ /^localhost$/i,
1568
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1569
+ /^0\.0\.0\.0$/,
1570
+ /^::1$/,
1571
+ /^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1572
+ /^192\.168\.\d{1,3}\.\d{1,3}$/,
1573
+ /^172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3}$/
1574
+ ];
1575
+ function isLocalDevHost(hostname) {
1576
+ var host = hostname.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
1577
+ if (!host) return false;
1578
+ if (host.endsWith(".local") || host.endsWith(".localhost")) return true;
1579
+ return PRIVATE_HOST_PATTERNS.some(function(pattern) {
1580
+ return pattern.test(host);
1581
+ });
1582
+ }
1583
+ function toDevSafeUrl(rawUrl) {
1584
+ if (!rawUrl) return rawUrl !== null && rawUrl !== void 0 ? rawUrl : "";
1585
+ var url;
1586
+ try {
1587
+ url = new URL(rawUrl);
1588
+ } catch (unused) {
1589
+ return rawUrl;
1590
+ }
1591
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
1592
+ return rawUrl;
1593
+ }
1594
+ if (!isLocalDevHost(url.hostname)) {
1595
+ return rawUrl;
1596
+ }
1597
+ var cleanPath = url.pathname.replace(/\/{2,}/g, "/") || "/index.html";
1598
+ return "file://".concat(cleanPath);
1599
+ }
1565
1600
  // src/sdk/pal.ts
1566
1601
  var PAL_SDK_URL = "https://imasdk.googleapis.com/pal/sdkloader/pal.js";
1567
1602
  var _nonceLoader;
@@ -1648,12 +1683,12 @@ function createPalNonceManager() {
1648
1683
  request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
1649
1684
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
1650
1685
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
1651
- request.descriptionUrl = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1686
+ request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1652
1687
  request.iconsSupported = true;
1653
1688
  request.playerType = "StormcloudVideoPlayer";
1654
1689
  request.playerVersion = "1.0";
1655
1690
  request.supportedApiFrameworks = "2,7,9";
1656
- request.url = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1691
+ request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1657
1692
  request.videoWidth = options.videoWidth || 640;
1658
1693
  request.videoHeight = options.videoHeight || 480;
1659
1694
  if (options.ppid) request.ppid = options.ppid;
@@ -5272,7 +5307,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5272
5307
  podMaxDurationMs: podParams.maxDurationMs,
5273
5308
  isCtv: envSignals.isCtv,
5274
5309
  contentUrl: envSignals.contentUrl,
5275
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5310
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
5276
5311
  adWillPlayMuted: adWillPlayMuted,
5277
5312
  adWillAutoPlay: !!this.config.autoplay,
5278
5313
  appId: envSignals.appId,