MCPcopy
hub / github.com/encode/httpx / percent_encoded

Function percent_encoded

httpx/_urlparse.py:482–494  ·  view source on GitHub ↗

Use percent-encoding to quote a string.

(string: str, safe: str)

Source from the content-addressed store, hash-verified

480
481
482def percent_encoded(string: str, safe: str) -> str:
483 """
484 Use percent-encoding to quote a string.
485 """
486 NON_ESCAPED_CHARS = UNRESERVED_CHARACTERS + safe
487
488 # Fast path for strings that don't need escaping.
489 if not string.rstrip(NON_ESCAPED_CHARS):
490 return string
491
492 return "".join(
493 [char if char in NON_ESCAPED_CHARS else PERCENT(char) for char in string]
494 )
495
496
497def quote(string: str, safe: str) -> str:

Callers 1

quoteFunction · 0.85

Calls 2

PERCENTFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected