@@ -30,8 +30,8 @@ Spacer.style = css`
3030
3131type OmniboxResult = {
3232 kind : "search" | "history" | "bookmark" | "direct" ;
33- title ?: string ;
34- url : string ;
33+ title ?: string | null ;
34+ url : URL ;
3535 favicon ?: string | null ;
3636} ;
3737
@@ -61,26 +61,23 @@ export const UrlInput: Component<
6161 for ( const entry of browser . globalhistory ) {
6262 if ( ! entry . url . href . includes ( search ) && ! entry . title ?. includes ( search ) )
6363 continue ;
64- if ( this . overflowItems . some ( ( i ) => i . url === entry . url . href ) ) continue ;
64+ if ( this . overflowItems . some ( ( i ) => i . url . href === entry . url . href ) )
65+ continue ;
6566
6667 this . overflowItems . push ( {
6768 kind : "history" ,
6869 title : entry . title ,
69- url : entry . url . href ,
70+ url : entry . url ,
7071 favicon : entry . favicon ,
7172 } ) ;
7273 }
7374 this . overflowItems = this . overflowItems . slice ( 0 , 5 ) ;
7475
75- if (
76- search . startsWith ( "http:" ) ||
77- search . startsWith ( "https:" ) ||
78- search . startsWith ( "puter:" )
79- ) {
76+ if ( URL . canParse ( search ) ) {
8077 this . overflowItems = [
8178 {
8279 kind : "direct" ,
83- url : search ,
80+ url : new URL ( search ) ,
8481 } ,
8582 ...this . overflowItems ,
8683 ] ;
@@ -101,7 +98,9 @@ export const UrlInput: Component<
10198 this . overflowItems . push ( {
10299 kind : "search" ,
103100 title : item ,
104- url : `https://www.google.com/search?q=${ encodeURIComponent ( item ) } ` ,
101+ url : new URL (
102+ `https://www.google.com/search?q=${ encodeURIComponent ( item ) } `
103+ ) ,
105104 favicon : scramjet . encodeUrl ( "https://www.google.com/favicon.ico" ) ,
106105 } ) ;
107106 }
@@ -118,7 +117,6 @@ export const UrlInput: Component<
118117 }
119118 if ( ratelimiting ) {
120119 if ( currentTimeout ) return ;
121- // TODO: why is it using the node types here
122120 currentTimeout = setTimeout ( ( ) => {
123121 ratelimiting = false ;
124122 fetchSuggestions ( ) ;
@@ -171,7 +169,7 @@ export const UrlInput: Component<
171169 this . active = false ;
172170 this . input . blur ( ) ;
173171
174- browser . activetab . pushNavigate ( new URL ( item . url ) ) ;
172+ browser . activetab . pushNavigate ( item . url ) ;
175173 } }
176174 class :focused = { use ( this . focusindex ) . map (
177175 ( i ) => i - 1 === this . overflowItems . indexOf ( item )
@@ -184,7 +182,7 @@ export const UrlInput: Component<
184182 />
185183 { ( item . title && < span class = "description" > { item . title } - </ span > ) ||
186184 "" }
187- < span class = "url" > { item . url } </ span >
185+ < span class = "url" > { trimUrl ( item . url ) } </ span >
188186 </ div >
189187 ) ) }
190188 </ div >
@@ -212,9 +210,8 @@ export const UrlInput: Component<
212210 if ( e . key === "Enter" ) {
213211 e . preventDefault ( ) ;
214212 if ( this . focusindex > 0 ) {
215- // this.value = this.overflowItems[this.focusindex - 1].;
216213 browser . activetab . pushNavigate (
217- new URL ( this . overflowItems [ this . focusindex - 1 ] . url )
214+ this . overflowItems [ this . focusindex - 1 ] . url
218215 ) ;
219216 this . active = false ;
220217 this . input . blur ( ) ;
0 commit comments