@@ -88,31 +88,31 @@ <h1>404</h1>
8888 </ a >
8989 </ div >
9090 < script >
91+ // Redirects github pages for repos that have moved to another org.
9192 ( function ( ) {
9293
9394 'use strict' ;
9495
95- var movedRepos = [
96- 'google-api-java-client' ,
97- 'google-api-nodejs-client' ,
98- 'google-api-python-client' ,
99- 'google-auth-library-java' ,
100- 'google-auth-library-nodejs' ,
101- 'google-http-java-client' ,
102- 'google-oauth-java-client' ,
103- 'oauth2client'
104- ] ;
105-
106- var pathname = location . pathname ;
107- if ( location . host != 'googleapis.github.io' ) {
108- var found = movedRepos . find ( function ( repo ) {
109- var regex = new RegExp ( '^/' + repo + '(/|$)' ) ;
110- return regex . test ( pathname ) ;
111- } ) ;
112- if ( found ) {
113- location . host = 'googleapis.github.io' ;
96+ // Mapping from repo name to the org it moved to.
97+ var movedRepos = {
98+ 'google-api-java-client' : 'googleapis' ,
99+ 'google-api-nodejs-client' : 'googleapis' ,
100+ 'google-api-python-client' : 'googleapis' ,
101+ 'google-auth-library-java' : 'googleapis' ,
102+ 'google-auth-library-nodejs' : 'googleapis' ,
103+ 'google-http-java-client' : 'googleapis' ,
104+ 'google-oauth-java-client' : 'googleapis' ,
105+ 'oauth2client' : 'googleapis'
106+ } ;
107+
108+ var repoRegex = new RegExp ( '^/([^/]+)(/|$)' ) ;
109+ var match = repoRegex . exec ( location . pathname ) ;
110+ if ( match ) {
111+ var newOrg = movedRepos [ match [ 1 ] ] ;
112+ if ( newOrg ) {
113+ location . host = newOrg + '.github.io' ;
114114 }
115- }
115+ }
116116
117117 } ( ) ) ;
118118 </ script >
0 commit comments