A Search Form That Produces a Shareable URL

A search form can express a read operation through query values on a GET request. The resulting URL can carry the chosen search state.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace one search
  2. Keep sensitive information out of the URL
  3. Reopen the resulting URL in an independent session
  4. Check defaults and clearing behavior

Trace one search

A form with q supplied as algebra can produce a books URL with that query. Opening the URL later can request the same filter against whatever content exists then. Query parameters supply the state.

Keep sensitive information out of the URL

URLs can remain in history and be copied. Treat search values appropriate for a shareable location separately from private form data. See diagnostic context and privacy.[1][2]

Reopen the resulting URL in an independent session

A search for a phrase containing spaces should yield a URL whose query preserves that phrase under the form's encoding. A copied URL can reproduce the public request outside the original tab. Use GET when submitting the form only requests a view. See URL components.

Search value: "rail maps"
Browser encodes a query parameter
Opening that URL recreates the same query input
User-specific access may still affect returned records

Check defaults and clearing behavior

Empty search and missing search can both lead to the unfiltered view if the application defines that. Record only filters intended to travel in the URL and test repeated submissions without creating any persisted change.

References

  1. IETF, RFC 9110: HTTP Semantics ↩
  2. WHATWG, HTML Living Standard: Forms ↩