| 406 | } |
| 407 | |
| 408 | func (m QueryFilter) processQueryString(s string) string { |
| 409 | u, err := url.Parse(s) |
| 410 | if err != nil { |
| 411 | return s |
| 412 | } |
| 413 | |
| 414 | q := u.Query() |
| 415 | for _, a := range m.Actions { |
| 416 | switch a.Type { |
| 417 | case replaceAction: |
| 418 | for i := range q[a.Parameter] { |
| 419 | q[a.Parameter][i] = a.Value |
| 420 | } |
| 421 | |
| 422 | case hashAction: |
| 423 | for i := range q[a.Parameter] { |
| 424 | q[a.Parameter][i] = hash(a.Value) |
| 425 | } |
| 426 | |
| 427 | case deleteAction: |
| 428 | q.Del(a.Parameter) |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | u.RawQuery = q.Encode() |
| 433 | return u.String() |
| 434 | } |
| 435 | |
| 436 | type cookieFilterAction struct { |
| 437 | // `replace` to replace the value of the cookie, `hash` to replace it with the 4 initial bytes of the SHA-256 of its content or `delete` to remove it entirely. |