mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
doc update
This commit is contained in:
@ -12,10 +12,8 @@ This parser will work with naked and wrapped URL strings:
|
||||
- `<scheme://host/path>`
|
||||
- `<URL:scheme://host/path>`
|
||||
|
||||
Two query representations are available and documented in the schema.
|
||||
|
||||
Normalized quoted and unquoted versions of the original URL are also
|
||||
included.
|
||||
Normalized quoted and unquoted versions of the original URL and URL parts
|
||||
are included in the output.
|
||||
|
||||
Usage (cli):
|
||||
|
||||
@ -29,52 +27,59 @@ Usage (module):
|
||||
Schema:
|
||||
|
||||
{
|
||||
"quoted": string,
|
||||
'unquoted": string,
|
||||
"scheme": string,
|
||||
"netloc": string,
|
||||
"path": string or null,
|
||||
"path_list": [ array or null
|
||||
string
|
||||
"url": string,
|
||||
'url_encoded": string,
|
||||
"scheme": string,
|
||||
"scheme_encoded": string,
|
||||
"netloc": string,
|
||||
"netloc_encoded": string,
|
||||
"path": string or null,
|
||||
"path_encoded": string or null,
|
||||
"path_list": [ array or null
|
||||
string
|
||||
],
|
||||
"query": { object or null
|
||||
<query-key>: [ array or null
|
||||
<query-value> string # [0]
|
||||
"query": string or Null,
|
||||
"query_encoded": string or Null,
|
||||
"query_obj": { object or null
|
||||
<query-key>: [ array or null
|
||||
<query-value> string # [0]
|
||||
]
|
||||
},
|
||||
"query_list": [ array or null
|
||||
[
|
||||
<query-key> string, # [1]
|
||||
<query-value> string
|
||||
]
|
||||
],
|
||||
"fragment": string or null,
|
||||
"username": string or null,
|
||||
"password": string or null,
|
||||
"hostname": string or null,
|
||||
"port": integer or null
|
||||
"fragment": string or null,
|
||||
"fragment_encoded": string or null,
|
||||
"username": string or null,
|
||||
"username_encoded": string or null,
|
||||
"password": string or null,
|
||||
"password_encoded": string or null,
|
||||
"hostname": string or null,
|
||||
"hostname_encoded": string or null,
|
||||
"port": integer or null,
|
||||
"port_encoded": string or null
|
||||
}
|
||||
|
||||
[0] Duplicate query-keys will have their values consolidated into the
|
||||
array of query-values
|
||||
[1] The first array value is the query-key and the second value is the
|
||||
query-value
|
||||
|
||||
Examples:
|
||||
|
||||
% echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\
|
||||
| jc --url -p
|
||||
{
|
||||
"quoted": "http://example.com/test/path?q1%3Dfoo%26q1%3Dbar%26q2%3Dbaz#frag",
|
||||
"unquoted": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
|
||||
"url_encoded": "http://example.com/test/path?q1%3Dfoo%26q1%3Dbar%26q2%3Dbaz#frag",
|
||||
"scheme": "http",
|
||||
"scheme_encoded": "http",
|
||||
"netloc": "example.com",
|
||||
"netloc_encoded": "example.com",
|
||||
"path": "/test/path",
|
||||
"path_encoded": "/test/path",
|
||||
"path_list": [
|
||||
"test",
|
||||
"path"
|
||||
],
|
||||
"query": {
|
||||
"query": "q1=foo&q1=bar&q2=baz",
|
||||
"query_encoded": "q1%3Dfoo%26q1%3Dbar%26q2%3Dbaz",
|
||||
"query_obj": {
|
||||
"q1": [
|
||||
"foo",
|
||||
"bar"
|
||||
@ -83,44 +88,44 @@ Examples:
|
||||
"baz"
|
||||
]
|
||||
},
|
||||
"query_list": [
|
||||
[
|
||||
"q1",
|
||||
"foo"
|
||||
],
|
||||
[
|
||||
"q1",
|
||||
"bar"
|
||||
],
|
||||
[
|
||||
"q2",
|
||||
"baz"
|
||||
]
|
||||
],
|
||||
"fragment": "frag",
|
||||
"fragment_encoded": "frag",
|
||||
"username": null,
|
||||
"username_encoded": null,
|
||||
"password": null,
|
||||
"password_encoded": null,
|
||||
"hostname": "example.com",
|
||||
"port": null
|
||||
"hostname_encoded": "example.com",
|
||||
"port": null,
|
||||
"port_encoded": null
|
||||
}
|
||||
|
||||
$ echo "ftp://localhost/filepath" | jc --url -p
|
||||
{
|
||||
"quoted": "ftp://localhost/filepath",
|
||||
"unquoted": "ftp://localhost/filepath",
|
||||
"url": "ftp://localhost/filepath",
|
||||
"url_encoded": "ftp://localhost/filepath",
|
||||
"scheme": "ftp",
|
||||
"scheme_encoded": "ftp",
|
||||
"netloc": "localhost",
|
||||
"netloc_encoded": "localhost",
|
||||
"path": "/filepath",
|
||||
"path_encoded": "/filepath",
|
||||
"path_list": [
|
||||
"filepath"
|
||||
],
|
||||
"query": null,
|
||||
"query_list": null,
|
||||
"query_encoded": null,
|
||||
"query_obj": null,
|
||||
"fragment": null,
|
||||
"fragment_encoded": null,
|
||||
"username": null,
|
||||
"username_encoded": null,
|
||||
"password": null,
|
||||
"password_encoded": null,
|
||||
"hostname": "localhost",
|
||||
"port": null
|
||||
"hostname_encoded": "localhost",
|
||||
"port": null,
|
||||
"port_encoded": null
|
||||
}
|
||||
|
||||
<a id="jc.parsers.url.parse"></a>
|
||||
|
Reference in New Issue
Block a user