mirror of
https://git.swurl.xyz/swirl/link.git
synced 2024-11-16 19:53:18 +00:00
decode url in query-string GET
todo: install target for nginx and systemd files
This commit is contained in:
parent
b05ae723ab
commit
994a47b02e
|
@ -44,7 +44,11 @@ A Minimal, SQLite-Backed URL Shortener
|
|||
| $ curl {{.URL}}/ddg?https://duckduckgo.com
|
||||
| {{.URL}}/ddg
|
||||
|
|
||||
| 5. Deleting a short link
|
||||
| 5. You can also pass an encoded URL:
|
||||
| $ curl {{.URL}}?https%3A%2F%2Fduckduckgo.com
|
||||
| {{.URL}}/1dc4cb37e81de396
|
||||
|
|
||||
| 6. Deleting a short link
|
||||
| $ TMP=$(mktemp)
|
||||
| $ # temp file will store header
|
||||
| $ LINK=$(curl -sS {{.URL}} -d https://duckduckgo.com -D $TMP)
|
||||
|
|
6
main.go
6
main.go
|
@ -171,7 +171,11 @@ func (c controller) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|||
|
||||
case http.MethodGet:
|
||||
st := strings.TrimRight(r.URL.Path, "/")
|
||||
rq := r.URL.RawQuery
|
||||
rq, err := url.QueryUnescape(r.URL.RawQuery)
|
||||
if err != nil {
|
||||
c.Err(rw, r, err)
|
||||
return
|
||||
}
|
||||
if rq != "" {
|
||||
u, err := url.Parse(rq)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue