diff --git a/pics/太神啦.png b/pics/太神啦.png new file mode 100644 index 0000000..923c4b6 Binary files /dev/null and b/pics/太神啦.png differ diff --git a/prefetch_test.go b/prefetch_test.go index 24e3e67..4fea632 100644 --- a/prefetch_test.go +++ b/prefetch_test.go @@ -16,7 +16,7 @@ func TestPrefetchImages(t *testing.T) { _ = os.Mkdir(fp, 0755) prefetchImages("./pics", "./prefetch", "80") count := fileCount("./prefetch") - assert.Equal(t, 6, count) + assert.Equal(t, 7, count) _ = os.RemoveAll(fp) // concurrency @@ -24,6 +24,6 @@ func TestPrefetchImages(t *testing.T) { _ = os.Mkdir(fp, 0755) prefetchImages("./pics", "./prefetch", "80") count = fileCount("./prefetch") - assert.Equal(t, 4, count) + assert.Equal(t, 5, count) _ = os.RemoveAll(fp) } diff --git a/router.go b/router.go index fbafff6..3ad2055 100644 --- a/router.go +++ b/router.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/gofiber/fiber/v2" log "github.com/sirupsen/logrus" + "net/url" "os" "path" "path/filepath" @@ -14,7 +15,7 @@ import ( func convert(c *fiber.Ctx) error { //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 imgFilename = path.Base(reqURI) // pure filename, 123.jpg var finalFile string // We'll only need one c.sendFile() diff --git a/router_test.go b/router_test.go index fdfe3d1..c736433 100644 --- a/router_test.go +++ b/router_test.go @@ -21,13 +21,15 @@ var ( func TestConvert(t *testing.T) { setupParam() var testChromeLink = map[string]string{ - "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.png": "image/webp", - "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/12314.jpg": "text/plain; charset=utf-8", - "http://127.0.0.1:3333/dir1/inside.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.png": "image/webp", + "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/12314.jpg": "text/plain; charset=utf-8", + "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{ diff --git a/scripts/webp_server.spec b/scripts/webp_server.spec index 9a8d61d..fa4bb4e 100644 --- a/scripts/webp_server.spec +++ b/scripts/webp_server.spec @@ -1,5 +1,5 @@ Name: webp-server -Version: 0.2.1 +Version: 0.2.2 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. diff --git a/webp-server.go b/webp-server.go index 0f7c759..161115c 100644 --- a/webp-server.go +++ b/webp-server.go @@ -28,7 +28,7 @@ var ( proxyMode bool config Config - version = "0.2.1" + version = "0.2.2" ) const (