http.pathEscape() function

The http.pathEscape() function escapes special characters in a string (including /) and replaces non-ASCII characters with hexadecimal representations (%XX).

*Function type: Transformation*

  1. import "http"
  2. http.pathEscape(
  3. inputString: "/this/is/an/example-path.html"
  4. )
  5. // Returns %2Fthis%2Fis%2Fan%2Fexample-path.html

Parameters

inputString

The string to escape.

*Data type: String*

Examples

URL-encode strings in a stream of tables
  1. import "http"
  2. data
  3. |> map(fn: (r) => ({ r with
  4. path: http.pathEscape(inputString: r.path)
  5. }))