mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
url with non-ascii fix, bump version
This commit has fixed issue reported in PR 57, add test case
This commit is contained in:
parent
08c333f3cd
commit
a67de53ae6
BIN
pics/太神啦.png
Normal file
BIN
pics/太神啦.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 328 KiB |
@ -16,7 +16,7 @@ func TestPrefetchImages(t *testing.T) {
|
|||||||
_ = os.Mkdir(fp, 0755)
|
_ = os.Mkdir(fp, 0755)
|
||||||
prefetchImages("./pics", "./prefetch", "80")
|
prefetchImages("./pics", "./prefetch", "80")
|
||||||
count := fileCount("./prefetch")
|
count := fileCount("./prefetch")
|
||||||
assert.Equal(t, 6, count)
|
assert.Equal(t, 7, count)
|
||||||
_ = os.RemoveAll(fp)
|
_ = os.RemoveAll(fp)
|
||||||
|
|
||||||
// concurrency
|
// concurrency
|
||||||
@ -24,6 +24,6 @@ func TestPrefetchImages(t *testing.T) {
|
|||||||
_ = os.Mkdir(fp, 0755)
|
_ = os.Mkdir(fp, 0755)
|
||||||
prefetchImages("./pics", "./prefetch", "80")
|
prefetchImages("./pics", "./prefetch", "80")
|
||||||
count = fileCount("./prefetch")
|
count = fileCount("./prefetch")
|
||||||
assert.Equal(t, 4, count)
|
assert.Equal(t, 5, count)
|
||||||
_ = os.RemoveAll(fp)
|
_ = os.RemoveAll(fp)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -14,7 +15,7 @@ import (
|
|||||||
|
|
||||||
func convert(c *fiber.Ctx) error {
|
func convert(c *fiber.Ctx) error {
|
||||||
//basic vars
|
//basic vars
|
||||||
var reqURI = c.Path() // /mypic/123.jpg
|
var reqURI, _ = url.QueryUnescape(c.Path()) // /mypic/123.jpg
|
||||||
var rawImageAbs = path.Join(config.ImgPath, reqURI) // /home/xxx/mypic/123.jpg
|
var rawImageAbs = path.Join(config.ImgPath, reqURI) // /home/xxx/mypic/123.jpg
|
||||||
var imgFilename = path.Base(reqURI) // pure filename, 123.jpg
|
var imgFilename = path.Base(reqURI) // pure filename, 123.jpg
|
||||||
var finalFile string // We'll only need one c.sendFile()
|
var finalFile string // We'll only need one c.sendFile()
|
||||||
|
@ -21,13 +21,15 @@ var (
|
|||||||
func TestConvert(t *testing.T) {
|
func TestConvert(t *testing.T) {
|
||||||
setupParam()
|
setupParam()
|
||||||
var testChromeLink = map[string]string{
|
var testChromeLink = map[string]string{
|
||||||
"http://127.0.0.1:3333/webp_server.jpg": "image/webp",
|
"http://127.0.0.1:3333/webp_server.jpg": "image/webp",
|
||||||
"http://127.0.0.1:3333/webp_server.bmp": "image/webp",
|
"http://127.0.0.1:3333/webp_server.bmp": "image/webp",
|
||||||
"http://127.0.0.1:3333/webp_server.png": "image/webp",
|
"http://127.0.0.1:3333/webp_server.png": "image/webp",
|
||||||
"http://127.0.0.1:3333/empty.jpg": "text/plain; charset=utf-8",
|
"http://127.0.0.1:3333/empty.jpg": "text/plain; charset=utf-8",
|
||||||
"http://127.0.0.1:3333/png.jpg": "image/webp",
|
"http://127.0.0.1:3333/png.jpg": "image/webp",
|
||||||
"http://127.0.0.1:3333/12314.jpg": "text/plain; charset=utf-8",
|
"http://127.0.0.1:3333/12314.jpg": "text/plain; charset=utf-8",
|
||||||
"http://127.0.0.1:3333/dir1/inside.jpg": "image/webp",
|
"http://127.0.0.1:3333/dir1/inside.jpg": "image/webp",
|
||||||
|
"http://127.0.0.1:3333/%e5%a4%aa%e7%a5%9e%e5%95%a6.png": "image/webp",
|
||||||
|
"http://127.0.0.1:3333/太神啦.png": "image/webp",
|
||||||
}
|
}
|
||||||
|
|
||||||
var testSafariLink = map[string]string{
|
var testSafariLink = map[string]string{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Name: webp-server
|
Name: webp-server
|
||||||
Version: 0.2.1
|
Version: 0.2.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: Go version of WebP Server. A tool that will serve your JPG/PNGs as WebP format with compression, on-the-fly.
|
Summary: Go version of WebP Server. A tool that will serve your JPG/PNGs as WebP format with compression, on-the-fly.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ var (
|
|||||||
|
|
||||||
proxyMode bool
|
proxyMode bool
|
||||||
config Config
|
config Config
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user