This is MySQL User Defined Function written by cgo.
Parse from url string to json object.
$ ./build.sh
(notice)
- require root privilege
(full)
MariaDB [(none)]> select json_detailed(ws_parse_url('https://user:pass@www.sample.com:8080/path/to/site.html?k1=v1&k2=v2&u[]=1&u[]=2#top')) as json;
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"scheme": "https",
"host": "www.sample.com",
"port": "8080",
"user": "user",
"pass": "pass",
"path": "/path/to/site.html",
"query": "k1=v1&k2=v2&u[]=1&u[]=2",
"params":
{
"k1":
[
"v1"
],
"k2":
[
"v2"
],
"u":
[
"1",
"2"
]
},
"fragment": "top"
} |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(only path & query)
MariaDB [(none)]> select json_detailed(ws_parse_url('/path/to/site.html?k1=v1&k2=v2&u[]=1&u[]=2')) as json;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"path": "/path/to/site.html",
"query": "k1=v1&k2=v2&u[]=1&u[]=2",
"params":
{
"k1":
[
"v1"
],
"k2":
[
"v2"
],
"u":
[
"1",
"2"
]
}
} |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(only path)
MariaDB [(none)]> select json_detailed(ws_parse_url('/path/to/site.html')) as json;
+--------------------------------------+
| json |
+--------------------------------------+
| {
"path": "/path/to/site.html"
} |
+--------------------------------------+
(only query)
MariaDB [(none)]> select json_detailed(ws_parse_url('?k1=v1&k2=v2&u[]=1&u[]=2')) as json;
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"query": "k1=v1&k2=v2&u[]=1&u[]=2",
"params":
{
"k1":
[
"v1"
],
"k2":
[
"v2"
],
"u":
[
"1",
"2"
]
}
} |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+