mirror of https://github.com/ansible/ansible.git
filter: fix documentation (#81113)
* Updated urldecode documentation * Misc typo fixes * Better formatting * Corrected some example Fixes: #81112 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/81299/head
parent
528e7859d0
commit
1e929ada6f
@ -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 O(query) is provided, a string or integer will be returned instead, depending on O(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"
|
||||
|
Loading…
Reference in New Issue