MCPcopy
hub / github.com/labstack/echo / TestDefaultRouter_UnescapePathParamValues

Function TestDefaultRouter_UnescapePathParamValues

router_test.go:3083–3172  ·  view source on GitHub ↗

See issue #1531, #1258 - there are cases when path parameter need to be unescaped

(t *testing.T)

Source from the content-addressed store, hash-verified

3081
3082// See issue #1531, #1258 - there are cases when path parameter need to be unescaped
3083func TestDefaultRouter_UnescapePathParamValues(t *testing.T) {
3084 var testCases = []struct {
3085 name string
3086 whenURL string
3087 expectPath string
3088 expectPathValues PathValues
3089 givenUnescapePathParamValues bool
3090 }{
3091 {
3092 name: "ok, unescape = true",
3093 givenUnescapePathParamValues: true,
3094 whenURL: "/first/value%20with%20space",
3095 expectPath: "/first/:raw",
3096 expectPathValues: PathValues{
3097 {
3098 Name: "raw",
3099 Value: "value with space",
3100 },
3101 },
3102 },
3103 {
3104 name: "ok, multiple, unescape = true",
3105 givenUnescapePathParamValues: true,
3106 whenURL: "/second/%20/with%20space",
3107 expectPath: "/second/:id/:fileName",
3108 expectPathValues: PathValues{
3109 {Name: "id", Value: " "},
3110 {Name: "fileName", Value: "with space"},
3111 },
3112 },
3113 {
3114 name: "ok, any route, unescape = true",
3115 givenUnescapePathParamValues: true,
3116 whenURL: "/third/%20%2Fwith%20space",
3117 expectPath: "/third/*",
3118 expectPathValues: PathValues{
3119 {Name: "*", Value: " /with space"},
3120 },
3121 },
3122 {
3123 name: "ok, ending with static node, unescape = true",
3124 givenUnescapePathParamValues: true,
3125 whenURL: "/fourth/%20%2Fwith%20space/static",
3126 expectPath: "/fourth/:id/static",
3127 expectPathValues: PathValues{
3128 {Name: "id", Value: " /with space"},
3129 },
3130 },
3131 {
3132 name: "ok, unescape = false",
3133 givenUnescapePathParamValues: false,
3134 whenURL: "/first/value%20with%20space",
3135 expectPath: "/first/:raw",
3136 expectPathValues: PathValues{
3137 {
3138 Name: "raw",
3139 Value: "value%20with%20space",
3140 },

Callers

nothing calls this directly

Calls 9

AddMethod · 0.95
PathMethod · 0.95
PathValuesMethod · 0.95
NewFunction · 0.85
NewRouterFunction · 0.85
NewContextMethod · 0.80
RouterMethod · 0.80
RouteMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…