browserSearch.ts ×8

Frontier kind: Code frontier

unlabeled · c_e981bc6d0efa

17 tests · 3605 LOC · 19 files · introduces 0 tests · 211 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges211 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
496 ranges3605 lines · 19 files · Browse complete extent
All tests (intent)
17 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationbrowserSearch.ts ×4 · 8 introduced LOCbrowserSearch.ts ×4browserSearch.ts ×6 · 15 introduced LOCbrowserSearch.ts ×6fragment is a URL (percent-encoded later)|occurrence=1, browserSearch.test|title=BrowserSearch - resolveAddressBarInput input is trimmed before classification|occurrence=1 · 0 introduced LOCfragment is a URL (perce…browserSearch.ts ×4 · 16 introduced LOCbrowserSearch.ts ×4browserSearch.ts ×2 · 5 introduced LOCbrowserSearch.ts ×2browserSearch.ts ×4 · 9 introduced LOCbrowserSearch.ts ×4browserSearch.ts ×6 · 13 introduced LOCbrowserSearch.ts ×6browserSearch.test|title=BrowserSearch - resolveAddressBarInput whitespace in the userinfo with an IP-literal host is still a URL|occurrence=1 · 0 introduced LOCbrowserSearch.test|title…browserSearch.ts ×2 · 4 introduced LOCbrowserSearch.ts ×2browserSearch.test|title=BrowserSearch - resolveAddressBarInput an explicit http(s) scheme keeps whitespace-userinfo input a URL|occurrence=1 · 0 introduced LOCbrowserSearch.test|title…browserSearch.ts ×2 · 7 introduced LOCbrowserSearch.ts ×2browserSearch.ts ×4 · 13 introduced LOCbrowserSearch.ts ×4browserSearch.ts ×1 · 2 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×2 · 5 introduced LOCbrowserSearch.ts ×2browserSearch.ts ×1 · 3 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 7 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 3 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×12 · 55 introduced LOCbrowserSearch.ts ×12browserSearch.ts ×1 · 2 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 2 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×3 · 3 introduced LOCbrowserSearch.ts ×3browserSearch.ts ×1 · 1 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 1 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 4 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 1 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 2 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 2 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×8 · 19 introduced LOCbrowserSearch.ts ×8browserSearch.ts ×1 · 1 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×1 · 1 introduced LOCbrowserSearch.ts ×1browserSearch.ts ×3 · 10 introduced LOCbrowserSearch.ts ×3browserSearch.ts ×1 · 5 introduced LOCbrowserSearch.ts ×1uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3nls.ts ×1 · 1 introduced LOCnls.ts ×1nls.ts ×6 · 13 introduced LOCnls.ts ×6lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/workbench/contrib/browserView/common/browserSearch.ts · 449 LOCcommon/browserSearch.tscharCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…browserSearch.test|title=BrowserSearch - buildSearchUrl encodes queries for each engine|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - buildSearchUrl encodes queries for each engine|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - buildSearchUrl encodes special characters|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - buildSearchUrl encodes special characters|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - buildSearchUrl trims and collapses internal whitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - buildSearchUrl trims and collapses internal whitespace|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - buildSearchUrl unknown engine id falls back to default (Bing)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - buildSearchUrl unknown engine id falls back to default (Bing)|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - getBrowserSearchEngineLabel returns the engine label, falling back to default for unknown ids|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - getBrowserSearchEngineLabel returns the engine label, falling back to default for unknown ids|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput ambiguous inputs return unknown|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput ambiguous inputs return unknown|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput an explicit http(s) scheme keeps whitespace-userinfo input a URL|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput an explicit http(s) scheme keeps whitespace-userinfo input a URL|occurrence=1browserSearch.test|title… whitespace input returns empty|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput empty / whitespace input returns empty|occurrence=1 whitespace input return…browserSearch.test|title=BrowserSearch - resolveAddressBarInput input is trimmed before classification|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput input is trimmed before classification|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput javascript: with non-code body is unknown|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput javascript: with non-code body is unknown|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput queries (whitespace or invalid host chars) return query|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput queries (whitespace or invalid host chars) return query|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput recognized schemes are URLs|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput recognized schemes are URLs|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput scheme-less hosts and IPs are URLs|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput scheme-less hosts and IPs are URLs|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput unknown scheme that looks like user:password@host is a URL|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput unknown scheme that looks like user:password@host is a URL|occurrence=1browserSearch.test|title…fragment is a URL (percent-encoded later)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput whitespace in the path/query/fragment is a URL (percent-encoded later)|occurrence=1fragment is a URL (perce…browserSearch.test|title=BrowserSearch - resolveAddressBarInput whitespace in the userinfo is unknown (defaults to search)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput whitespace in the userinfo is unknown (defaults to search)|occurrence=1browserSearch.test|title…browserSearch.test|title=BrowserSearch - resolveAddressBarInput whitespace in the userinfo with an IP-literal host is still a URL|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/browserView/test/common/browserSearch.test|title=BrowserSearch - resolveAddressBarInput whitespace in the userinfo with an IP-literal host is still a URL|occurrence=1browserSearch.test|title…Focused concept · browserSearch.ts ×8 · 211 introduced LOCbrowserSearch.ts ×8

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 211 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/browserView/common/browserSearch.ts 211 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- browserSearch.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > /*
7 > * NOTE: {@link resolveAddressBarInputType} is a deliberate, self-contained
8 > * APPROXIMATION of Chromium's omnibox parser (`AutocompleteInput::Parse`), not
9 > * a faithful port. It intentionally diverges in places — most notably it uses a
10 > * lightweight "any 2+ letter last label is a TLD" heuristic instead of a Public
11 > * Suffix List lookup — to avoid maintaining large data tables for an address
12 > * bar. Please treat the unit tests in `browserSearch.test.ts` as the
13 > * specification: do not "fix" this to byte-match Chromium. If Chromium's
14 > * behavior changes in a way we care about, re-sync deliberately and update the
15 > * tests.
16 > */
17 >
18 > import { localize } from '../../../../nls.js';
19 >
20 > /**
21 > * Identifier of the integrated browser address bar search engine.
22 > */
23 > export enum BrowserSearchEngineId {
24 > Bing = 'bing',
25 > Google = 'google',
26 > Yahoo = 'yahoo',
27 > DuckDuckGo = 'duckduckgo',
28 > }
29 >
30 > export const BrowserSearchEngineSettingId =
31 > 'workbench.browser.searchEngine';
32 >
33 > /**
34 > * Value of {@link BrowserSearchEngineSettingId} when no search engine is
35 > * selected (address bar search disabled). Selecting any other value both
36 > * enables search and picks the engine.
37 > */
38 > export const BROWSER_SEARCH_NONE = 'none';
39 >
40 > /**
41 > * The address bar search setting value: either `'none'` (search disabled) or a
42 > * specific {@link BrowserSearchEngineId}.
43 > */
44 > export type BrowserSearchEngineValue = BrowserSearchEngineId | typeof BROWSER_SEARCH_NONE;
45 >
46 > /**
47 > * A search engine that can be selected as the integrated browser's default.
48 > */
49 > export interface IBrowserSearchEngine {
50 > readonly id: BrowserSearchEngineId;
51 > /** Human-readable label shown in the settings UI. */
52 > readonly label: string;
53 > /**
54 > * Build a search URL for the given query string. The query is the raw
55 > * (already trimmed) user input; implementations are responsible for
56 > * URL-encoding it.
57 > */
58 > buildSearchUrl(query: string): string;
59 > }
60 >
61 > /**
62 > * Encode a search query for use in a search-engine URL. Matches the encoding
63 > * used by popular browsers: `encodeURIComponent` then replace `%20` with `+`.
64 > */
65 function encodeQuery(query: string): string {
66 return encodeURIComponent(query).replace(/%20/g, '+');
67 }
69 > /**
70 > * Ordered list of supported search engines.
71 > */
72 > export const BROWSER_SEARCH_ENGINES: readonly IBrowserSearchEngine[] = [
73 > {
74 > id: BrowserSearchEngineId.Bing,
75 > label: localize('browser.search.engine.bing', "Bing"),
76 > buildSearchUrl: (q) => `https://www.bing.com/search?q=${encodeQuery(q)}`,
77 > },
78 > {
79 > id: BrowserSearchEngineId.Google,
80 > label: localize('browser.search.engine.google', "Google"),
81 > buildSearchUrl: (q) => `https://www.google.com/search?q=${encodeQuery(q)}`,
82 > },
83 > {
84 > id: BrowserSearchEngineId.Yahoo,
85 > label: localize('browser.search.engine.yahoo', "Yahoo!"),
86 > buildSearchUrl: (q) =>
87 `https://search.yahoo.com/search?p=${encodeQuery(q)}`,
89 > {
90 > id: BrowserSearchEngineId.DuckDuckGo,
91 > label: localize('browser.search.engine.duckduckgo', "DuckDuckGo"),
92 > buildSearchUrl: (q) => `https://duckduckgo.com/?q=${encodeQuery(q)}`,
93 > },
94 > ];
95 >
96 > /**
97 > * Classification of an address bar input. Mirrors the four non-deprecated
98 > * values of Chromium's `metrics::OmniboxInputType`:
99 > * - `'empty'`: input is whitespace-only.
100 > * - `'url'`: input is recognized as a navigable URL.
101 > * - `'query'`: input is recognized as a search query (or an invalid URL that
102 > * can only reasonably be treated as a query).
103 > * - `'unknown'`: input is ambiguous — could be a URL (e.g. an intranet host
104 > * or new TLD) or a search; callers should default to search but may offer
105 > * a "did you mean to navigate?" affordance.
106 > */
107 > export type AddressBarInputKind = 'empty' | 'url' | 'query' | 'unknown';
108 >
109 > /**
110 > * Known URL schemes other than http/https and javascript. Anything in this
111 > * set is classified as URL when typed as a leading `scheme:` prefix.
112 > */
113 > const KNOWN_URL_SCHEMES = new Set([
114 > 'file',
115 > 'ftp',
116 > 'ftps',
117 > 'about',
118 > 'data',
119 > 'view-source',
120 > 'mailto',
121 > 'chrome',
122 > 'edge',
123 > 'vscode',
124 > 'vscode-insiders',
125 > ]);
126 >
127 > /**
128 > * All schemes that we recognize as actual URL schemes (used to disambiguate
129 > * `scheme:operand` from `host:port` — e.g. `localhost:3000` looks like a
130 > * scheme syntactically but `localhost` is not a known scheme).
131 > */
132 > const ALL_KNOWN_SCHEMES = new Set<string>([...KNOWN_URL_SCHEMES, 'http', 'https', 'javascript']);
133 >
134 > /**
135 > * Special-cased TLDs from RFC 6761 / RFC 6762 / ICANN that are treated as
136 > * known only when a subdomain is present. `.invalid` is reserved as
137 > * non-navigable.
138 > */
139 > const SUBDOMAIN_REQUIRED_TLDS = new Set(['example', 'test', 'local', 'internal']);
140 >
141 > const SCHEME_REGEX = /^([a-z][a-z0-9+\-.]*):/i;
142 > const JAVASCRIPT_QUERY_REGEX = /^javascript:[^;=().\"]*$/i;
143 > const USERINFO_WITH_PASSWORD_REGEX = /^[^\s:@/?#]+:[^\s@/?#]+@/;
144 > const HOST_CHARS_REGEX = /^[a-zA-Z0-9\-._~%]+$/;
145 > const PORT_REGEX = /^\d+$/;
146 > const IPV4_REGEX = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
147 >
148 > /**
149 > * Canonicalize a hostname using the platform's URL parser. Converts
150 > * non-ASCII (IDN) hostnames to their punycode (`xn--`) form, and validates
151 > * and canonicalizes bracketed IPv6 literals (e.g. `[2001:0db8::0001]` →
152 > * `[2001:db8::1]`). Returns `undefined` if the host can't be canonicalized.
153 > * ASCII non-bracket hosts are returned unchanged (validation happens via
154 > * `HOST_CHARS_REGEX` at the call site).
155 > */
156 function toAsciiHost(host: string): string | undefined {
157 const needsUrlParse = host.startsWith('[') || !/^[\x00-\x7F]*$/.test(host);
165 }
166 }
168 > interface IParsedAuthority {
169 > readonly userinfo: string | undefined;
170 > readonly host: string;
171 > readonly port: string | undefined;
172 > readonly pathAndRest: string;
173 > }
174 >
175 function parseHostAndPath(rest: string): IParsedAuthority {
176 const sepMatch = /[/?#]/.exec(rest);
212 return { userinfo, host, port, pathAndRest };
213 }
215 function hasKnownTld(host: string): boolean {
216 const trimmed = host.toLowerCase().replace(/\.$/, '');
239 return false;
240 }
242 > /**
243 > * Classify a raw address bar input as one of the four non-deprecated
244 > * `metrics::OmniboxInputType` values: `empty`, `url`, `query`, or `unknown`.
245 > *
246 > * Adapted from Chromium's `AutocompleteInput::Parse`.
247 > * Reference: https://chromium.googlesource.com/chromium/src/+/1a40eab3d2faacd167cc3d78d20f9da98d55b78e/components/omnibox/browser/autocomplete_input.cc#250
248 > *
249 > * - Empty / whitespace-only input → `empty`.
250 > * - Recognized non-http(s) scheme (`file:`, `ftp:`, `about:`, `data:`,
251 > * `view-source:`, `mailto:`, `chrome:`, `edge:`, `vscode:`, …) → `url`.
252 > * - `javascript:` followed by something that doesn't look like code → `unknown`.
253 > * - Unknown scheme that looks like `user:password@host…` → `url`. Other
254 > * unknown schemes (e.g. `site:foo`) → `unknown`.
255 > * - http(s) or scheme-less input is then parsed into authority + path:
256 > * - Whitespace in the host → `query`; whitespace in the userinfo → `unknown`
257 > * (unless an explicit http(s) scheme is present). Whitespace in the
258 > * path/query/fragment is allowed — it is percent-encoded at navigation
259 > * time, matching Chromium (which only rejects whitespace inside the
260 > * host/username, not the rest of the URL).
261 > * - Invalid host characters → `query`.
262 > * - Bracketed IPv6 literal → `url`.
263 > * - Dotted-quad IPv4 with first octet != 0 (or exactly `0.0.0.0`) → `url`;
264 > * other "IPv4-ish" inputs (e.g. `0.1.2.3`, single component like `13.5`)
265 > * fall through to the heuristics below.
266 > * - `localhost` (with optional port/path) → `url`.
267 > * - Explicit http/https scheme → `url`.
268 > * - Trailing slash on the path → `url` (intranet shortcut).
269 > * - Explicit port → `url`.
270 > * - Host with a known TLD (any 2+ letter last label, punycode IDN, or a
271 > * subdomain of `example`/`test`/`local`/`internal`) → `url`.
272 > * - `user@host` (without explicit TLD) → `unknown` (more likely an email).
273 > * - More than one non-host component present → `url`.
274 > * - Anything else (single word, host with unknown TLD) → `unknown`.
275 > *
276 > * Callers typically map `url` → navigate, and `query` / `unknown` → search.
277 > * `empty` is returned for whitespace-only input so callers can short-circuit.
278 > */
279 > export function resolveAddressBarInputType(rawInput: string): AddressBarInputKind {
280 const trimmed = rawInput.trim();
281 if (trimmed.length === 0) {
423 return 'unknown';
424 }
426 > /**
427 > * Build a search URL for the given query using the specified engine. The
428 > * query is trimmed and collapses internal whitespace before encoding.
429 > */
430 > export function buildSearchUrl(
431 query: string,
432 engineId: BrowserSearchEngineId,
437 return engine.buildSearchUrl(query.trim().replace(/\s+/g, ' '));
438 }
440 > /**
441 > * Human-readable label for the given search engine (e.g. "Bing"). Falls back
442 > * to the default engine's label for an unknown id.
443 > */
444 > export function getBrowserSearchEngineLabel(engineId: BrowserSearchEngineId): string {
445 const engine =
446 BROWSER_SEARCH_ENGINES.find((e) => e.id === engineId) ??