(in []byte, inArgs []interface{})
| 14 | ) |
| 15 | |
| 16 | func expandQuery(in []byte, inArgs []interface{}) ([]byte, []interface{}) { |
| 17 | out := make([]byte, 0, len(in)) |
| 18 | outArgs := make([]interface{}, 0, len(inArgs)) |
| 19 | |
| 20 | i := 0 |
| 21 | for i < len(in) && len(inArgs) > 0 { |
| 22 | if in[i] == '?' { |
| 23 | out = append(out, in[:i]...) |
| 24 | in = in[i+1:] |
| 25 | i = 0 |
| 26 | |
| 27 | replace, replaceArgs := expandArgument(inArgs[0]) |
| 28 | inArgs = inArgs[1:] |
| 29 | |
| 30 | if len(replace) > 0 { |
| 31 | replace, replaceArgs = expandQuery(replace, replaceArgs) |
| 32 | out = append(out, replace...) |
| 33 | } else { |
| 34 | out = append(out, '?') |
| 35 | } |
| 36 | |
| 37 | outArgs = append(outArgs, replaceArgs...) |
| 38 | continue |
| 39 | } |
| 40 | i = i + 1 |
| 41 | } |
| 42 | |
| 43 | if len(out) < 1 { |
| 44 | return in, inArgs |
| 45 | } |
| 46 | |
| 47 | out = append(out, in[:]...) |
| 48 | in = nil |
| 49 | |
| 50 | outArgs = append(outArgs, inArgs[:]...) |
| 51 | inArgs = nil |
| 52 | |
| 53 | return out, outArgs |
| 54 | } |
| 55 | |
| 56 | func expandArgument(arg interface{}) ([]byte, []interface{}) { |
| 57 | values, isSlice := toInterfaceArguments(arg) |
no test coverage detected