@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.28.5-redoc-alpha6",
3
+ "version": "1.28.5-redoc-alpha7",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -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
- if (this.cameFromSameOriginPage()) {
115
- window.history.back();
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 true only when the page was reached via in-tab navigation from
126
- * a same-origin page, so `history.back()` is safe to call. Checks both
127
- * `initialHistoryLength` and `document.referrer` since neither signal is
128
- * reliable on its own.
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 cameFromSameOriginPage(): boolean {
131
+ private getSameOriginReferrerHref(): string | null {
131
132
  if (this.initialHistoryLength <= 1 || !document.referrer) {
132
- return false;
133
+ return null;
133
134
  }
134
135
  try {
135
- return new URL(document.referrer).origin === window.location.origin;
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 false;
142
+ return null;
138
143
  }
139
144
  }
140
145