File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
src/pydata_sphinx_theme/assets/scripts Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -316,18 +316,21 @@ async function fetchVersionSwitcherJSON(url) {
316
316
} catch ( err ) {
317
317
// if not, assume relative path and fix accordingly
318
318
if ( err instanceof TypeError ) {
319
- result = new URL ( url , window . location . origin ) ;
319
+ // workaround for redirects like https://pydata-sphinx-theme.readthedocs.io
320
+ // fetch() automatically follows redirects so it should work in every builder
321
+ // (RDT, GitHub actions, etc)
322
+ const origin = await fetch ( window . location . origin , {
323
+ method : "HEAD" ,
324
+ } ) . then ( ( res ) => {
325
+ return res . url ;
326
+ } ) ;
327
+ result = new URL ( url , origin ) ;
320
328
} else {
321
329
throw err ;
322
330
}
323
331
}
324
- // workaround for redirects like https://pydata-sphinx-theme.readthedocs.io
325
- // fetch() automatically follows redirects so it should work in every builder
326
- // (RDT, GitHub actions, etc)
327
- const finalURL = await fetch ( result , { method : "HEAD" } ) . then ( ( res ) => {
328
- return res . url ;
329
- } ) ;
330
- const response = await fetch ( finalURL ) ;
332
+
333
+ const response = await fetch ( result ) ;
331
334
const data = await response . json ( ) ;
332
335
return data ;
333
336
}
You can’t perform that action at this time.
0 commit comments