Skip to content

Commit 86f1050

Browse files
committed
🧑‍💻 update skill
1 parent 3e1b19a commit 86f1050

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

skills/qs-codec/SKILL.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: qs-codec
3-
description: Use this skill whenever a user wants to install, configure, troubleshoot, or write Python application code for encoding and decoding nested query strings with the qs-codec package, including composing qs-codec with urllib.parse URL components. This skill helps produce practical qs_codec.decode, qs_codec.encode, qs_codec.loads, and qs_codec.dumps snippets, choose DecodeOptions and EncodeOptions, explain option tradeoffs, and avoid qs-codec edge-case pitfalls around lists, dot notation, duplicates, null handling, charset sentinels, depth limits, URL replacement, and untrusted input.
3+
description: Use this skill whenever a user wants to install, configure, troubleshoot, or write Python application code for encoding and decoding nested query strings with the qs-codec package, including comparing or composing qs-codec with urllib.parse.urlencode, parse_qs, parse_qsl, and URL components. This skill helps produce practical qs_codec.decode, qs_codec.encode, qs_codec.loads, and qs_codec.dumps snippets, choose DecodeOptions and EncodeOptions, explain option tradeoffs, and avoid qs-codec edge-case pitfalls around lists, dot notation, duplicates, null handling, charset sentinels, depth limits, URL replacement, and untrusted input.
44
---
55

66
# qs-codec Usage Assistant
@@ -71,6 +71,46 @@ assert query == "a%5Bb%5D%5Bc%5D=d&tags%5B0%5D=python&tags%5B1%5D=web"
7171
Use `qs.loads(...)` as a string-only alias for `qs.decode(...)`, and
7272
`qs.dumps(...)` as an alias for `qs.encode(...)`.
7373

74+
## Standard-Library Codec Selection
75+
76+
Choose `urllib.parse.urlencode`, `parse_qs`, and `parse_qsl` for conventional
77+
flat `application/x-www-form-urlencoded` data. Choose `qs-codec` when callers
78+
need nested dictionaries or lists, Node `qs` interoperability, configurable
79+
list, duplicate, or null semantics, or matching structure-aware encode/decode
80+
behavior.
81+
82+
Apply these distinctions when comparing the APIs:
83+
84+
- Treat `urlencode` as a flat encoder. With `doseq=True`, expand sequence
85+
values as repeated keys; use `ListFormat.REPEAT` for the equivalent
86+
`qs.encode` output. Do not pass nested mappings to `urlencode` expecting
87+
recursive query paths.
88+
- Account for different defaults: `urlencode` emits spaces as `+` and uses
89+
Python scalar spellings such as `True` and `None`; `qs.encode` defaults to
90+
`%20`, lowercase booleans, and an empty value for `None`.
91+
- Treat `parse_qs` as a grouped flat parser whose dictionary values are always
92+
lists. It leaves bracket syntax in literal keys, drops blanks unless
93+
`keep_blank_values=True`, and cannot distinguish a name-only token from an
94+
explicit empty value.
95+
- Prefer `parse_qsl` when flat pair order and interleaved duplicates matter. It
96+
returns an ordered list of name/value pairs, but otherwise shares
97+
`parse_qs`'s literal bracket, blank-value, and null-distinction limitations.
98+
It also percent-decodes names and values and normalizes `+` and `%20`, so do
99+
not present its output as a lossless representation of the raw query.
100+
- Use `qs.decode` to reconstruct bracket or dot paths. A singleton normally
101+
remains scalar, duplicate policies support combine/first/last, and
102+
`strict_null_handling=True` distinguishes a bare name as `None` from an
103+
explicit empty string.
104+
- Note that all three parsers leave primitive values as strings. `parse_qs` and
105+
`qs.decode` combine repeated flat keys by default, while `parse_qsl` retains
106+
each occurrence. For resource limits, compare the standard-library parsers'
107+
`max_num_fields` with `DecodeOptions.parameter_limit`, `depth`, and
108+
`list_limit` plus `raise_on_limit_exceeded`.
109+
110+
Do not preprocess a complete URL's raw query with `parse_qs` or `parse_qsl`
111+
before `qs.decode`; doing so flattens structured syntax and loses name-only
112+
distinctions.
113+
74114
## Standard-Library URL Recipes
75115

76116
Use `urllib.parse.urlsplit` to separate URL parsing from qs decoding. Pass the

0 commit comments

Comments
 (0)