mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-07-16 17:26:58 -04:00
## What Adds [OpenSearch](https://developer.mozilla.org/en-US/docs/Web/XML/Guides/OpenSearch) support so browsers can register a `ce` keyword. Once registered, typing `ce <shortlink>` in the address bar redirects to `/z/<shortlink>`. ## How - **`views/opensearch.pug`** — an OpenSearch 1.1 description document. - **`/search.xml` route** (`lib/app/server-config.ts`) — mirrors the existing `/sitemap.xml` route; serves the doc with `Content-Type: application/opensearchdescription+xml`. - **`views/meta.pug`** — advertises it via `<link rel="search">` on the main page (omitted on embed pages, where OpenSearch discovery doesn't apply). The search URL template (`…/z/{searchTerms}`) is built from the request (`{protocol}://{host}{httpRoot}`, the same pattern as `lib/storage/base.ts`), and the favicon uses the env-resolved `staticRoot`/`faviconFilename`, so it's correct across prod/beta/staging/local. ## Activation note This is opt-in *discovery*, not automatic activation — browsers register the engine after visiting the site, and the user typically activates the `ce` keyword once (Chrome: Settings → Search engines → Site search; Firefox surfaces it in the address bar). Chrome's auto-discovery is also gated on a secure context, so this is best validated on an HTTPS environment (e.g. staging/beta) rather than a plain-HTTP dev box. ## Testing Verified against a local instance: - `GET /search.xml` → `200`, correct content-type, well-formed XML, `{searchTerms}` placeholder preserved, `<Url template>` absolute and host-derived. - `<link rel="search">` present on `/`, absent on `/e`. - favicon URL resolves. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>