Refactors Cover's Extension cleaning in Album
This commit is contained in:
@@ -8,9 +8,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"ponyo.epfl.ch/gitlab/alexandre.tuleu/narco"
|
||||
|
||||
@@ -20,8 +18,6 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var rxExt = regexp.MustCompile(`[0-9]+`)
|
||||
|
||||
func (a *appData) buildRouter() http.Handler {
|
||||
router := httprouter.New()
|
||||
|
||||
@@ -79,9 +75,7 @@ func (a *appData) buildRouter() http.Handler {
|
||||
}
|
||||
|
||||
album := *albumUnsafe
|
||||
ext := path.Ext(album.CoverURL)
|
||||
ext = strings.ToLower(rxExt.ReplaceAllString(ext, ""))
|
||||
album.CoverURL = fmt.Sprintf("/covers/%d%s", album.ID, ext)
|
||||
album.CoverURL = fmt.Sprintf("/covers/%d%s", album.ID, album.CoverExt())
|
||||
|
||||
enc := json.NewEncoder(w)
|
||||
if err := enc.Encode(album); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user