diff options
Diffstat (limited to 'lib/ansible/plugins/filter/urldecode.yml')
-rw-r--r-- | lib/ansible/plugins/filter/urldecode.yml | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/lib/ansible/plugins/filter/urldecode.yml b/lib/ansible/plugins/filter/urldecode.yml index dd76937b..8208f013 100644 --- a/lib/ansible/plugins/filter/urldecode.yml +++ b/lib/ansible/plugins/filter/urldecode.yml @@ -1,48 +1,29 @@ DOCUMENTATION: - name: urlsplit + name: urldecode version_added: "2.4" - short_description: get components from URL + short_description: Decode percent-encoded sequences description: - - Split a URL into its component parts. - positional: _input, query + - Replace %xx escapes with their single-character equivalent in the given string. + - Also replace plus signs with spaces, as required for unquoting HTML form values. + positional: _input options: _input: - description: URL string to split. + description: URL encoded string to decode. type: str required: true - query: - description: Specify a single component to return. - type: str - choices: ["fragment", "hostname", "netloc", "password", "path", "port", "query", "scheme", "username"] RETURN: _value: description: - - A dictionary with components as keyword and their value. - - If I(query) is provided, a string or integer will be returned instead, depending on I(query). + - URL decoded value for the given string type: any EXAMPLES: | - {{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit }} - # => - # { - # "fragment": "fragment", - # "hostname": "www.acme.com", - # "netloc": "user:password@www.acme.com:9000", - # "password": "password", - # "path": "/dir/index.html", - # "port": 9000, - # "query": "query=term", - # "scheme": "http", - # "username": "user" - # } - - {{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit('hostname') }} - # => 'www.acme.com' - - {{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit('query') }} - # => 'query=term' + # Decode urlencoded string + {{ '%7e/abc+def' | urldecode }} + # => "~/abc def" - {{ "http://user:password@www.acme.com:9000/dir/index.html?query=term#fragment" | urlsplit('path') }} - # => '/dir/index.html' + # Decode plus sign as well + {{ 'El+Ni%C3%B1o' | urldecode }} + # => "El NiƱo" |