See issue #1531, #1258 - there are cases when path parameter need to be unescaped
(t *testing.T)
| 3081 | |
| 3082 | // See issue #1531, #1258 - there are cases when path parameter need to be unescaped |
| 3083 | func 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 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…