URLEncode

Encodes a URL string by replacing special characters in the string using the %xx escape. For example: https://example.com converts to https:%2F%2Fexample.com.

python · Filters And Transformers

Source

from urllib.parse import quote, unquote

import demistomock as demisto
from CommonServerPython import *

""" MAIN FUNCTION """


def main():
    try:
        args = demisto.args()
        value = args.get("value")
        decoded_value = unquote(value)
        if argToBoolean(args.get("ignore_safe_character", "false")):
            return_results(quote(decoded_value, safe=""))
        else:
            return_results(quote(decoded_value, safe=args.get("safe_character", "/")))
    except Exception as exc:
        return_error(f"Failed to execute URLEncode.\nError: {exc!s}", error=exc)


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()  # pragma: no cover

README

Encodes a URL string by replacing special characters in the string using the %xx escape. For example: https://example.com converts to https:%2F%2Fexample.com.

Script Data


Name Description
Script Type python3
Tags transformer
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
value The URL to encode.

Outputs


There are no outputs for this script.