| 1 |
# URL Functions |
| 2 |
|
| 3 |
## urlParse |
| 4 |
Parses string for URL and produces dict with URL parts |
| 5 |
|
| 6 |
``` |
| 7 |
urlParse "http://admin:[email protected]:8080/api?list=false#anchor" |
| 8 |
``` |
| 9 |
|
| 10 |
The above returns a dict, containing URL object: |
| 11 |
```yaml |
| 12 |
scheme: 'http' |
| 13 |
host: 'server.com:8080' |
| 14 |
path: '/api' |
| 15 |
query: 'list=false' |
| 16 |
opaque: nil |
| 17 |
fragment: 'anchor' |
| 18 |
userinfo: 'admin:secret' |
| 19 |
``` |
| 20 |
|
| 21 |
For more info, check https://golang.org/pkg/net/url/#URL |
| 22 |
|
| 23 |
## urlJoin |
| 24 |
Joins map (produced by `urlParse`) to produce URL string |
| 25 |
|
| 26 |
``` |
| 27 |
urlJoin (dict "fragment" "fragment" "host" "host:80" "path" "/path" "query" "query" "scheme" "http") |
| 28 |
``` |
| 29 |
|
| 30 |
The above returns the following string: |
| 31 |
``` |
| 32 |
proto://host:80/path?query#fragment |
| 33 |
``` |