https://github.com/vedranvuk/urlvars
Package urlvars implements utilities for parsing elements of an URL into named values.
https://github.com/vedranvuk/urlvars
go golang url url-parser variables
Last synced: 28 days ago
JSON representation
Package urlvars implements utilities for parsing elements of an URL into named values.
- Host: GitHub
- URL: https://github.com/vedranvuk/urlvars
- Owner: vedranvuk
- License: mit
- Created: 2020-03-04T08:31:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-08T20:05:11.000Z (almost 5 years ago)
- Last Synced: 2025-02-05T09:30:01.541Z (3 months ago)
- Topics: go, golang, url, url-parser, variables
- Language: Go
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# urlvars
Package urlvars implements utilities for parsing elements of an URL into named values.
## Example
### UrlVars
```
template := https://www.example.com/:root/:sub/:file
rawurl := https://www.example.com/users/vedran/.listfiles.sh?action=list#listing
values, err := Path(template, rawurl)
// values will be:
// map[string]string{"root": "users", "sub": "vedran", "file": ".listfiles.sh"}
```### Expander
```
// Given an example url:
//
// https://user:[email protected]:80/users/vedran/file.ext?action=view&mode=quick#top
//
// The following supported keys would return the following values:
//
// scheme: scheme part of URL, "https://"
// userinfo: userinfo part of URL, "user:pass@"
// host: host part of URL, "www.example.com:80"
// hostname: host part of URL, "www.example.com"
// port: port part of URL, ":80"
// path: path part of URL, "/users/vedran/file.ext"
// query: query part of URL, "?action=view&mode=quick"
// fragment: query part of URL, "#top"
//
// Example:rawurl = https://user:[email protected]:80/users/vedran/file.ext?action=view&mode=quick#top
template = {scheme}{userinfo}{hostname}{port}{path}{query}{fragment}Expand(template, exampleurl)
// Output: https://user:[email protected]:80/users/vedran/file.ext?action=view&mode=quick#top
```## Documentation
[Godoc](https://godoc.org/github.com/vedranvuk/urlvars)
## License
See included LICENSE.