{
  "id": 11583947,
  "title": "Preserve plus signs and ampersands in demo search URLs",
  "url": "https://urgent.news/2026/10/03/preserve-plus-signs-and-ampersands-in-demo-search-urls",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-03T02:35:15.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/stavleak-hackathons/preserve-plus-signs-and-ampersands-in-demo-search-urls-2ejb"
  },
  "original_language": "en",
  "account": "When building search parameters for a web application, it's crucial to preserve special characters like plus signs and ampersands in user input to ensure the search function works correctly. If a user types a query with multiple words or additional symbols, such as \"C++ & design,\" the application must handle those characters properly.\n\nConcatenating the user's input into a query string can cause issues because the ampersand character can be interpreted as a separator between parameters, while the plus sign is used to represent spaces in form-style query syntax. To avoid these problems, it's recommended to use a URL object and the URLSearchParams interface.\n\nFirst, create a URL object with the base address of the search page. Then, use the set method of the URLSearchParams object to add the user's query as a parameter. This method automatically handles the serialization and encoding of special characters, ensuring they are represented correctly in the query string.\n\nFor example, if the user inputs \"C++ & design,\" the set method will serialize the value as \"q=C++%20%26%20design,\" with the plus sign and ampersand properly encoded. To retrieve the original query from the URL, create a new URL object using the serialized link and access the value of the \"q\" parameter using the get method of URLSearchParams. This will restore the original query, including any plus signs or ampersands.\n\nIt's also important to test the application with various inputs, including those containing special characters, spaces, or non-English characters. This will help ensure the application handles all types of user input correctly and displays the results as expected. Remember to keep query handling separate from HTML rendering, as correct serialization does not automatically make arbitrary text safe to insert as HTML.",
  "summary": "Build search parameters from raw values with URLSearchParams so a plus sign or ampersand in the user's input survives the round trip. A prototype may work with a single word and fail with a team name such as C++ & design. Concatenating that value into a query string gives punctuation another job: an ampersand can separate parameters, and a plus sign in form-style query syntax can be decoded as a…",
  "key_points": [
    "Preserve plus signs and ampersands in user input",
    "Use URL object and URLSearchParams interface",
    "Test with various special character inputs"
  ],
  "editors_take": "Properly handling special characters in search queries changes how web applications process user input, ensuring that searches for terms with plus signs and ampersands return accurate results.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}