@salesforcedevs/docs-components 1.34.1-doc-phase-redoc-2 → 1.34.1-doc-phase-redoc-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.
package/package.json
CHANGED
|
@@ -768,15 +768,21 @@ export default class RedocReference extends LightningElement {
|
|
|
768
768
|
// Inserts the doc phase and, on a non-latest version, a dismissible
|
|
769
769
|
// "newer version" banner into a shared doc-phase-wrapper at container start
|
|
770
770
|
private insertStatusItems(container: HTMLElement): void {
|
|
771
|
-
const items: HTMLElement[] = [];
|
|
772
|
-
|
|
773
771
|
const docPhaseInfo = this.getDocPhaseInfo();
|
|
772
|
+
if (!docPhaseInfo && !this.oldVersionInfo) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const wrapper = document.createElement("div");
|
|
777
|
+
wrapper.className = "doc-phase-wrapper";
|
|
778
|
+
container.insertBefore(wrapper, container.firstChild);
|
|
779
|
+
|
|
774
780
|
if (docPhaseInfo) {
|
|
775
781
|
const docPhaseElement = createElement("doc-phase", {
|
|
776
782
|
is: DocPhase
|
|
777
783
|
});
|
|
778
784
|
Object.assign(docPhaseElement, { docPhaseInfo });
|
|
779
|
-
|
|
785
|
+
wrapper.appendChild(docPhaseElement);
|
|
780
786
|
}
|
|
781
787
|
|
|
782
788
|
if (this.oldVersionInfo) {
|
|
@@ -790,17 +796,8 @@ export default class RedocReference extends LightningElement {
|
|
|
790
796
|
versionBanner.remove();
|
|
791
797
|
this.updateSidebarPosition();
|
|
792
798
|
});
|
|
793
|
-
|
|
799
|
+
wrapper.appendChild(versionBanner);
|
|
794
800
|
}
|
|
795
|
-
|
|
796
|
-
if (!items.length) {
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
const wrapper = document.createElement("div");
|
|
801
|
-
wrapper.className = "doc-phase-wrapper";
|
|
802
|
-
items.forEach((item) => wrapper.appendChild(item));
|
|
803
|
-
container.insertBefore(wrapper, container.firstChild);
|
|
804
801
|
}
|
|
805
802
|
|
|
806
803
|
// Appends footer component to container
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { CoveoAnalyticsClient } from "coveo.analytics/dist/browser.mjs"; // This fix is required for Node 20 upgrade, so that Coveo analytics is loaded properly by LWR.
|
|
2
2
|
|
|
3
|
+
// Resolve against the current origin (version links are usually relative) and
|
|
4
|
+
// keep only http/https. Blocks executable schemes like javascript:/data: that
|
|
5
|
+
// would run when the innerHTML-rendered link is clicked
|
|
6
|
+
// encodeURI then keeps the value from breaking out of the href attribute.
|
|
7
|
+
const toSafeHref = (link: string): string => {
|
|
8
|
+
try {
|
|
9
|
+
const { protocol } = new URL(link, window.location.origin);
|
|
10
|
+
if (protocol === "http:" || protocol === "https:") {
|
|
11
|
+
return encodeURI(link);
|
|
12
|
+
}
|
|
13
|
+
} catch {
|
|
14
|
+
// Fall through to the rejection below.
|
|
15
|
+
}
|
|
16
|
+
console.warn(`Blocked unsafe version link: ${link}`);
|
|
17
|
+
return "#";
|
|
18
|
+
};
|
|
19
|
+
|
|
3
20
|
export const oldVersionDocInfo = (latestVersionLink: string) => {
|
|
4
|
-
|
|
5
|
-
const safeLink = encodeURI(latestVersionLink);
|
|
21
|
+
const safeLink = toSafeHref(latestVersionLink);
|
|
6
22
|
return {
|
|
7
23
|
title: "Newer Version Available",
|
|
8
24
|
body: `This content describes an older version of this product.
|