URL manipulation made simple.
65
Build a helper that adjusts multivalue query parameters on a URL while preserving order and returning the final values for a target key. Operations run in order: replacements overwrite listed keys, additions append new entries afterward, and an optional removal then drops a single matching occurrence.
@generates
from typing import Dict, List, Optional, Tuple
def apply_query_controls(
url: str,
additions: Dict[str, List[str]],
removal: Optional[Tuple[str, str]],
replacements: Dict[str, List[str]],
read_key: str,
) -> Tuple[str, List[str]]:
"""
Adjust multivalue query parameters on the given URL.
- `replacements` overwrites all existing values for listed keys with the provided lists, in the order given.
- Each list in `additions` then appends individual query entries after current values for that key, preserving overall ordering of other keys.
- `removal`, when provided, removes one matching value for the given key without disturbing other values for that key.
- Returns a tuple of the updated URL string and the ordered values for `read_key` after all operations.
"""Provides URL parsing and ordered multivalue query handling.
Install with Tessl CLI
npx tessl i tessl/pypi-furlevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10