File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,12 @@ Page not found
3535
3636 // Check for redirects if on a currently invalid page.
3737 // This is done in JavaScript, as we exceed Read the Docs' limit for the amount of redirects configurable.
38- // When testing this feature on a local web server, replace the URL below with just `/_static/redirects.csv`.
39- fetch (" /en/latest/_static/redirects.csv" )
38+
39+ const currentPathSegments = window .location .pathname .split (' /' ).filter (segment => segment !== ' ' );
40+ // Use the base path (e.g. "/en/latest") when available.
41+ const currentBasePath = (currentPathSegments .length >= 2 ) ? (" /" + currentPathSegments .slice (0 , 2 ).join (" /" )) : " /" ;
42+
43+ fetch (currentBasePath + " /_static/redirects.csv" )
4044 .then (response => response .text ())
4145 .then (csvText => {
4246 const lines = csvText .trim ().split (' \n ' );
You can’t perform that action at this time.
0 commit comments