Skip to content

shigenobu/mysql_ws_parse_url

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ws_parse_url - MySQL UDF for parse url.

about

This is MySQL User Defined Function written by cgo.
Parse from url string to json object.

how to install

$ ./build.sh

(notice)

  • require root privilege

example

(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"
        ]
    }
} |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

About

MySQL UDF for parse url.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published