do performs the substring replacement on r.
(r *http.Request, repl *caddy.Replacer)
| 463 | |
| 464 | // do performs the substring replacement on r. |
| 465 | func (rep substrReplacer) do(r *http.Request, repl *caddy.Replacer) { |
| 466 | if rep.Find == "" { |
| 467 | return |
| 468 | } |
| 469 | |
| 470 | lim := rep.Limit |
| 471 | if lim == 0 { |
| 472 | lim = -1 |
| 473 | } |
| 474 | |
| 475 | find := repl.ReplaceAll(rep.Find, "") |
| 476 | replace := repl.ReplaceAll(rep.Replace, "") |
| 477 | |
| 478 | mergeSlashes := !strings.Contains(rep.Find, "//") |
| 479 | |
| 480 | changePath(r, func(pathOrRawPath string) string { |
| 481 | return strings.Replace(caddyhttp.CleanPath(pathOrRawPath, mergeSlashes), find, replace, lim) |
| 482 | }) |
| 483 | |
| 484 | r.URL.RawQuery = strings.Replace(r.URL.RawQuery, find, replace, lim) |
| 485 | } |
| 486 | |
| 487 | // regexReplacer describes a replacement using a regular expression. |
| 488 | type regexReplacer struct { |
nothing calls this directly
no test coverage detected