Analysieren URL query strings
Abfrage Zeichenketten bestehen Schlüssel-Wert pairs in URLs nach der ?. Lernen parsing, Kodierung, und handling von Arrays, nested Objekte, und special Zeichen.
- 1
A query string starts after ? in a URL: ?key=value&key2=value2. Keys and values are percent-encoded (spaces → %20 or +, special characters → %XX). Multiple values for the same key can use array notation: ?colors[]=red&colors[]=blue. Nested objects: ?user[name]=Alice&user[age]=30.
- 2 URL-Parser →
Analysieren a full URL to extract the query string as an object. The parser handles percent-decoding, array notation, and nested objects. Verify that special characters and Unicode are correctly decoded.
- 3 URL-Dekodierer →
Dekodieren a percent-encoded query string value. %20 → space, %2F → /, %3F → ?, %E4%B8%AD → 中 (UTF-8). The + character decodes to space in query strings (but %20 in path segments).
- 4 url-decode → hex-encode
Use the URL decode workflow to decode and analyze query string parameters, handling double-encoding and nested parameters.
Häufige Fragen
- What is the difference between + and %20 for spaces?
- In query strings, both + and %20 represent a space (application/x-www-form-urlencoded). In URL path segments, only %20 is a space — + is a literal plus sign. This inconsistency is a common source of bugs. Use %20 for paths, and either in query strings.
- How do I pass arrays in query strings?
- Common conventions: ?ids[]=1&ids[]=2 (PHP/Rails), ?ids=1&ids=2 (repeated key), ?ids=1,2 (comma-separated). There is no standard — choose one and document it. The repeated key form (?ids=1&ids=2) is the most widely supported.