MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Browser / tryNavigate

Function tryNavigate

wvbrowser_ui/controls_ui/default.js:175–207  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

173}
174
175function tryNavigate(text) {
176 try {
177 var uriParser = new URL(text);
178
179 // URL creation succeeded, verify protocol is allowed
180 switch (uriParser.protocol) {
181 case 'http:':
182 case 'https:':
183 case 'file:':
184 case 'ftp:':
185 // Allowed protocol, navigate
186 navigateActiveTab(uriParser.href, false);
187 break;
188 default:
189 // Protocol not allowed, search Bing
190 navigateActiveTab(getSearchURI(text), true);
191 break;
192 }
193 } catch (e) {
194 // URL creation failed, check for invalid characters
195 if (containsIlegalCharacters(text) || isSingleWord(text)) {
196 // Search Bing
197 navigateActiveTab(getSearchURI(text), true);
198 } else {
199 // Try with HTTP
200 if (!hasScheme(text)) {
201 tryNavigate(`http:${text}`);
202 } else {
203 navigateActiveTab(getSearchURI(text), true);
204 }
205 }
206 }
207}
208
209function navigateActiveTab(uri, isSearch) {
210 var message = {

Callers 1

processAddressBarInputFunction · 0.85

Calls 5

navigateActiveTabFunction · 0.85
getSearchURIFunction · 0.85
containsIlegalCharactersFunction · 0.85
isSingleWordFunction · 0.85
hasSchemeFunction · 0.85

Tested by

no test coverage detected