$(pathescape)
- Syntax
$(pathescape <text>)- Arguments
- Required
The $(pathescape) variable is a utility function in the StreamElements Chatbot that escapes a string for safe use in a URL path. It converts spaces and special characters into their percent-encoded equivalents, ensuring that the resulting string can be used as part of a valid URL.
Use it
Section titled “Use it”!command add !wiki Read all about it: https://en.wikipedia.org/wiki/$(pathescape ${1:})To use $(pathescape), include it in your command or message with the string you want to escape as its parameter:
$(pathescape <text>)Replace <text> with the text you want to encode for use in a URL path.
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”Input:
$(pathescape "Hello World!")Output:
Hello%20World%21Using with $(customapi)
Section titled “Using with $(customapi)”Input:
$(customapi "https://api.example.com/$(pathescape 'User Input & Symbols?')")Fetches:
https://api.example.com/User%20Input%20&%20Symbols%3FNote that characters which are valid inside a URL path segment (such as &, :, and =) are left as-is — only characters that would break the path (spaces, ?, /, and similar) are encoded.
Parameters
Section titled “Parameters”The $(pathescape) variable accepts a single parameter:
- text: The text you want to escape for use in a URL path. This parameter is required.
If no text is provided, the variable is not replaced and appears as literal text in the response.
Aliases
Section titled “Aliases”$(pathencode) can also be used as an alias for $(pathescape).
Related Variables
Section titled “Related Variables”$(queryescape): Escapes text for use in URL query parameters (encodes spaces as+).$(customapi): Fetches content from a URL, often combined with$(pathescape)for dynamic requests.
Q: What characters does $(pathescape) encode?
A: It percent-encodes spaces (as %20) and any characters that are not safe inside a URL path segment, such as ? and /. Characters that are valid in a path segment, like & and :, are left unchanged.
Q: What’s the difference between $(pathescape) and $(queryescape)?
A: $(pathescape) is for the path portion of a URL and encodes spaces as %20. $(queryescape) is for query parameters (everything after ?) and encodes spaces as +.