PageSourceSearch

https://int.diasorin.com/themes/custom/diasorin_theme/js/addtocalendar-fix.js?v=10.6.17

js diasorin.com collected 2026-09-24 19:20:57 UTC 1,868 bytes, 62 lines download raw bytes

1(function (Drupal, once) {
2  'use strict';
3
4  function normalizeAddToCalendarHref(link) {
5    if (!link || !link.getAttribute) {
6      return;
7    }
8
9    var href = link.getAttribute('href');
10    if (!href || href.indexOf('addtocalendar.com/atc/') === -1) {
11      return;
12    }
13
14    try {
15      var url = new URL(href, window.location.origin);
16
17      if (url.hostname === 'addtocalendar.com') {
18        url.protocol = 'https:';
19        url.hostname = 'addtocalendar.com';
20
21        // Keep endpoint canonical to avoid insecure redirect hops.
22        url.pathname = url.pathname.replace(/\/?$/, '/');
23
24        link.setAttribute('href', url.toString());
25      }
26    }
27    catch (e) {
28      // Ignore malformed URLs and leave untouched.
29    }
30  }
31
32  /**
33   * Force secure AddToCalendar provider URLs.
34   *
35   * Some generated provider links can redirect through http first, which causes
36   * modern browsers to block iCal/Outlook downloads on https pages.
37   */
38  Drupal.behaviors.diasorinAddToCalendarFix = {
39    attach: function (context) {
40      once('diasorin-addtocalendar-fix', '.addtocalendar', context).forEach(function (widget) {
41        var links = widget.querySelectorAll('.atcb-item-link[href*="addtocalendar.com/atc/"]');
42
43        links.forEach(function (link) {
44          normalizeAddToCalendarHref(link);
45        });
46      });
47
48      // Some AddToCalendar links are created dynamically after click/open.
49      once('diasorin-addtocalendar-fix-delegate', 'body', context).forEach(function (body) {
50        body.addEventListener('click', function (event) {
51          var link = event.target && event.target.closest
52            ? event.target.closest('.atcb-item-link[href*="addtocalendar.com/atc/"]')
53            : null;
54
55          if (link) {
56            normalizeAddToCalendarHref(link);
57          }
58        }, true);
59      });
60    }
61  };
62})(Drupal, once);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.