diff --git a/public/style.css b/public/style.css index 0e3d355..feca1c5 100644 --- a/public/style.css +++ b/public/style.css @@ -548,9 +548,6 @@ form.blockpost { .expando.open{ display: block; } -.expando .embed { - text-align: center; -} .expando .image { max-width: 578px; } diff --git a/routes.go b/routes.go index e8add21..e4d45cb 100644 --- a/routes.go +++ b/routes.go @@ -12,6 +12,7 @@ import ( "net/http" "net/url" "os" + "path/filepath" "regexp" "strconv" "strings" @@ -111,9 +112,13 @@ var funcMap = template.FuncMap{ } return "" }, - "isImage": func(url string) bool { - ext := url[len(url)-4:] - if ext == "jpeg" || ext == ".jpg" || ext == ".png" || ext == "webp" || ext == ".gif" { + "isImage": func(u string) bool { + p, err := url.Parse(u) + if err != nil || p.Path == "" { + return false + } + ext := filepath.Ext(p.Path) + if ext == ".jpeg" || ext == ".jpg" || ext == ".png" || ext == ".webp" || ext == ".gif" { return true } return false