@@ -19,14 +19,12 @@ export const SiteNav = (props: Props) => {
1919 const i = createInternational < typeof navCopy > ( useIntl ( ) )
2020 const IntlLink = createIntlLink ( props . lang )
2121 const loadDocSearch = ( ) => {
22- const isDev = document . location . host . includes ( 'localhost' )
23- let customHandleSelected ;
24-
25- if ( isDev ) {
26- customHandleSelected = ( input , event , suggestion , datasetNumber , context ) => {
27- const urlToOpen = suggestion . url . replace ( "www.typescriptlang.org" , "localhost:8000" ) . replace ( "https" , "http" )
28- window . open ( urlToOpen )
29- }
22+ const fixURL = ( url : string ) => {
23+ const u = new URL ( url ) ;
24+ if ( u . host === document . location . host ) return url ;
25+ u . host = document . location . host ;
26+ u . protocol = document . location . protocol ;
27+ return u . toString ( ) ;
3028 }
3129
3230 // @ts -ignore - this comes from the script above
@@ -35,7 +33,13 @@ export const SiteNav = (props: Props) => {
3533 apiKey : '37ee06fa68db6aef451a490df6df7c60' ,
3634 indexName : 'typescriptlang' ,
3735 inputSelector : '.search input' ,
38- handleSelected : customHandleSelected ,
36+ transformData : ( hits ) => {
37+ for ( const hit of hits ) {
38+ if ( hit . url ) hit . url = fixURL ( hit . url ) ;
39+ if ( hit . url_without_anchor ) hit . url_without_anchor = fixURL ( hit . url_without_anchor ) ;
40+ }
41+ return hits ;
42+ }
3943 } ) ;
4044 }
4145 // This extra bit of mis-direction ensures that non-essential code runs after
0 commit comments