mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Fixed url.PathUnescape for go1.7
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
c05db06020
commit
dc0f2d7327
3
echo.go
3
echo.go
@ -45,7 +45,6 @@ import (
|
|||||||
stdLog "log"
|
stdLog "log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -435,7 +434,7 @@ func (e *Echo) Static(prefix, root string) {
|
|||||||
|
|
||||||
func static(i i, prefix, root string) {
|
func static(i i, prefix, root string) {
|
||||||
h := func(c Context) error {
|
h := func(c Context) error {
|
||||||
p, err := url.PathUnescape(c.Param("*"))
|
p, err := PathUnescape(c.Param("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -76,7 +75,7 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc {
|
|||||||
if strings.HasSuffix(c.Path(), "*") { // When serving from a group, e.g. `/static*`.
|
if strings.HasSuffix(c.Path(), "*") { // When serving from a group, e.g. `/static*`.
|
||||||
p = c.Param("*")
|
p = c.Param("*")
|
||||||
}
|
}
|
||||||
p, err = url.PathUnescape(p)
|
p, err = echo.PathUnescape(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
12
util_go17.go
Normal file
12
util_go17.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// +build go1.7,!go1.8
|
||||||
|
|
||||||
|
package echo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PathUnescape is wraps `url.QueryUnescape`
|
||||||
|
func PathUnescape(s string) (string, error) {
|
||||||
|
return url.QueryUnescape(s)
|
||||||
|
}
|
10
util_go18.go
Normal file
10
util_go18.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// +build go1.8
|
||||||
|
|
||||||
|
package echo
|
||||||
|
|
||||||
|
import "net/url"
|
||||||
|
|
||||||
|
// PathUnescape is wraps `url.PathUnescape`
|
||||||
|
func PathUnescape(s string) (string, error) {
|
||||||
|
return url.PathUnescape(s)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user