@@ -3,17 +3,27 @@ let newVersion = "";
3
3
let currentVersion = "" ;
4
4
let fileRequested = "" ;
5
5
6
+ // Get the base URL dynamically
7
+ function getBaseUrl ( ) {
8
+
9
+ // Fallback to current origin
10
+ return `${ window . location . protocol } //${ window . location . host } /` ;
11
+ }
12
+
13
+ const baseUrl = getBaseUrl ( ) ;
14
+
15
+ // Use relative paths in the mappings
6
16
const urlMappings = {
7
- "openshift-acs" : "https://docs.openshift.com/ acs/" ,
8
- "openshift-builds" : "https://docs.openshift.com/ builds/" ,
9
- "openshift-enterprise" : "https://docs.openshift.com/ container-platform/" ,
10
- "openshift-gitops" : "https://docs.openshift.com/ gitops/" ,
11
- "openshift-lightspeed" : "https://docs.openshift.com/ lightspeed/" ,
12
- "openshift-origin" : "https://docs.okd.io/ " ,
13
- "openshift-pipelines" : "https://docs.openshift.com/ pipelines/" ,
14
- "openshift-serverless" : "https://docs.openshift.com/ serverless/" ,
15
- "openshift-telco" : "https://docs.openshift.com/ container-platform-telco/" ,
16
- "openshift-logging" : "https://docs.openshift.com/ logging/" ,
17
+ "openshift-acs" : "acs/" ,
18
+ "openshift-builds" : "builds/" ,
19
+ "openshift-enterprise" : "container-platform/" ,
20
+ "openshift-gitops" : "gitops/" ,
21
+ "openshift-lightspeed" : "lightspeed/" ,
22
+ "openshift-origin" : "" ,
23
+ "openshift-pipelines" : "pipelines/" ,
24
+ "openshift-serverless" : "serverless/" ,
25
+ "openshift-telco" : "container-platform-telco/" ,
26
+ "openshift-logging" : "logging/" ,
17
27
} ;
18
28
19
29
function versionSelector ( list ) {
@@ -27,11 +37,14 @@ function versionSelector(list) {
27
37
currentVersion = window . location . pathname . split ( "/" ) [ 2 ] ;
28
38
}
29
39
30
- let baseUrl = urlMappings [ dk ] ;
40
+ // Get the correct URL path from the urlMappings and prepend the base URL
41
+ let productPath = urlMappings [ dk ] ;
42
+ let fullBaseUrl = baseUrl + productPath ;
43
+
31
44
32
45
//Handle special OCP case
33
46
if ( [ "3.0" , "3.1" , "3.2" ] . includes ( newVersion ) && dk === "openshift-enterprise" ) {
34
- baseUrl = "https://docs.openshift.com/enterprise/" ;
47
+ fullBaseUrl = "https://docs.openshift.com/enterprise/" ;
35
48
}
36
49
37
50
if ( ( dk === "openshift-enterprise" || dk === "openshift-origin" ) && currentVersion . charAt ( 0 ) !== newVersion . charAt ( 0 ) ) {
@@ -41,7 +54,7 @@ function versionSelector(list) {
41
54
fileRequested = window . location . pathname . substring ( versionIndex ) ;
42
55
}
43
56
44
- newLink = `${ baseUrl } ${ newVersion } ${ fileRequested } ` ;
57
+ newLink = `${ fullBaseUrl } ${ newVersion } ${ fileRequested } ` ;
45
58
46
59
// without doing async loads, there is no way to know if the path actually
47
60
// exists - so we will just have to load
0 commit comments