1
Fork 0

Directly join short link string

This commit is contained in:
Jan-Lukas Else 2020-03-29 19:05:01 +02:00
parent 9d557f5272
commit c6552f825f
1 changed files with 1 additions and 8 deletions

View File

@ -9,7 +9,6 @@ import (
"log"
"math/rand"
"net/http"
"net/url"
"time"
)
@ -82,13 +81,7 @@ func ShortenHandler(w http.ResponseWriter, r *http.Request) {
}
writeShortenedUrl := func(w http.ResponseWriter, slug string) {
shortenedUrl, err := url.Parse(viper.GetString("shortUrl"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
shortenedUrl.Path = slug
_, _ = w.Write([]byte(shortenedUrl.String()))
_, _ = w.Write([]byte(viper.GetString("shortUrl") + "/" + slug))
}
requestUrl := r.URL.Query().Get("url")