@salesforcedevs/docs-components 1.28.5-redoc-alpha6 → 1.28.5-redoc-alpha7
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
|
@@ -37,7 +37,7 @@ type ReferenceConfig = {
|
|
|
37
37
|
const SCROLL_THROTTLE_DELAY = 50;
|
|
38
38
|
const ELEMENT_TIMEOUT = 10000;
|
|
39
39
|
const ELEMENT_CHECK_INTERVAL = 100;
|
|
40
|
-
const REFERENCES_SEGMENT = "/references";
|
|
40
|
+
const REFERENCES_SEGMENT = "/references/";
|
|
41
41
|
|
|
42
42
|
export default class RedocReference extends LightningElement {
|
|
43
43
|
private _referenceConfig: ReferenceConfig = { refList: [] };
|
|
@@ -111,8 +111,9 @@ export default class RedocReference extends LightningElement {
|
|
|
111
111
|
*/
|
|
112
112
|
private onBackClick = (event: Event): void => {
|
|
113
113
|
event.preventDefault();
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const referrerHref = this.getSameOriginReferrerHref();
|
|
115
|
+
if (referrerHref) {
|
|
116
|
+
window.location.href = referrerHref;
|
|
116
117
|
return;
|
|
117
118
|
}
|
|
118
119
|
const fallbackHref = this.getReferencesRootHref();
|
|
@@ -122,19 +123,23 @@ export default class RedocReference extends LightningElement {
|
|
|
122
123
|
};
|
|
123
124
|
|
|
124
125
|
/**
|
|
125
|
-
* Returns
|
|
126
|
-
* a same-origin page
|
|
127
|
-
*
|
|
128
|
-
*
|
|
126
|
+
* Returns the referrer URL when the page was reached via in-tab navigation
|
|
127
|
+
* from a same-origin page; otherwise `null`. Both `initialHistoryLength`
|
|
128
|
+
* and `document.referrer` are checked since neither signal is reliable on
|
|
129
|
+
* its own.
|
|
129
130
|
*/
|
|
130
|
-
private
|
|
131
|
+
private getSameOriginReferrerHref(): string | null {
|
|
131
132
|
if (this.initialHistoryLength <= 1 || !document.referrer) {
|
|
132
|
-
return
|
|
133
|
+
return null;
|
|
133
134
|
}
|
|
134
135
|
try {
|
|
135
|
-
|
|
136
|
+
const referrerUrl = new URL(document.referrer);
|
|
137
|
+
if (referrerUrl.origin !== window.location.origin) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return referrerUrl.href;
|
|
136
141
|
} catch {
|
|
137
|
-
return
|
|
142
|
+
return null;
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
|