Skip to content

$(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.

!command add !wiki Read all about it: https://en.wikipedia.org/wiki/$(pathescape ${1:})
Example chat
ViewerName:!wiki rocket league
partner badgemoderator badgeStreamElements:Read all about it: https://en.wikipedia.org/wiki/rocket%20league

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.

Input:

$(pathescape "Hello World!")

Output:

Hello%20World%21

Input:

$(customapi "https://api.example.com/$(pathescape 'User Input & Symbols?')")

Fetches:

https://api.example.com/User%20Input%20&%20Symbols%3F

Note 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.

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.

$(pathencode) can also be used as an alias for $(pathescape).

  • $(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 +.