✨ Add Firefox search engine support #46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ossfx43d8146f/v2-web:feat/43-opensearch-query-search"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #43
Problem
Firefox and other compliant browsers could not install the site as a search engine because there was no OpenSearch description or search-engine autodiscovery link.
The application also had no shareable search URL state: it ignored query parameters on startup and did not update the address bar after submitting a search. External browser search therefore could not open the site directly with results.
Root cause
src/index.htmldid not expose<link rel="search">autodiscovery.AppHeader.vuewas always an empty string.App.vuedid not parse the URL during startup and its search method only updated local component state before opening the SSE API stream.Solution
q, withqueryaccepted as a compatibility fallback, and canonicalize the address bar toq.history.replaceStateafter search submission, avoiding extra history entries and without adding a router dependency.src/public/opensearch.xml, which Vite copies to the site root, and reference it fromsrc/index.html.https://playsearch.kaki87.net/?q={searchTerms}and include the Firefoxmoz:SearchForm.URL contract
https://playsearch.kaki87.net/?q=firefoxopens the page and immediately searches forfirefox.?query=firefoxalso run the search and are normalized to?q=firefox.Files changed
src/components/App.vue: parse initial query, synchronize URL state, and trigger startup search.src/components/AppHeader.vue: initialize the input from the route-derived query.src/index.html: expose the OpenSearch description to browsers.src/public/opensearch.xml: define the browser search plugin and Firefox search form.Verification
yarn install --frozen-lockfile --ignore-scripts: success; dependencies already up to date. Existing peer/dependency warnings were unchanged.yarn build: success; 121 modules transformed. The only warnings were the existing browser externalization notices forlaunchdarkly-eventsourceNode built-ins.git diff --check upstream/master...HEAD: passed with no whitespace errors.src/public/opensearch.xmlanddist/opensearch.xmlas XML and verified the search template and Firefox search form.distand intercepted the production SSE endpoint in the browser with deterministic data:/?q=firefoxpopulated the input, requestedquery=firefox, rendered the result, preserved the URL, and exposed the OpenSearch link.browserrequestedquery=browserand updated both the input and URL to?q=browser./?query=legacy-queryrequestedlegacy-queryand normalized the URL to?q=legacy-query.firefox,browser, andlegacy-query.The project has no automated
testnpm script, so the production build plus the browser/SSE smoke test were used as the local equivalent.Compatibility and risk
replaceStateupdates the current history entry instead of creating a redirect or additional history entry.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.