QQueryNest
Workflows

Coding workflows · Ordered URL query pairs

03
Built around your work

A concrete starting point

Append one URL query pair while preserving repeated keys, blank values and their original order. Distinguish a literal plus encoded as %2B from a space and reject malformed percent escapes or invalid UTF-8.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Ordered URL query pairs

A concrete starting point
import re
from urllib.parse import parse_qsl, urlencode

def append_query(query, key, value):
    if any(type(x) is not str for x in (query, key, value)):
        raise ValueError("query.type")
    if re.search(r"%(?![0-9A-Fa-f]{2})", query):
        raise ValueError("query.escape")
    pairs = parse_qsl(query, keep_blank_values=True,
                      strict_parsing=True, errors="strict", max_num_fields=1000)
    return urlencode([*pairs, (key, value)])

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗