splitPos returns the index where path should be split based on t.SplitPath. example: if splitPath is [".php"] "/path/to/script.php/some/path": ("/path/to/script.php", "/some/path") Matching is strictly ASCII case-insensitive. Bytes >= utf8.RuneSelf in path never match any split entry: split string
(path string)
| 431 | // |
| 432 | // Adapted from FrankenPHP's code (copyright 2026 Kévin Dunglas, MIT license) |
| 433 | func (t Transport) splitPos(path string) int { |
| 434 | // TODO: from v1... |
| 435 | // if httpserver.CaseSensitivePath { |
| 436 | // return strings.Index(path, r.SplitPath) |
| 437 | // } |
| 438 | if len(t.SplitPath) == 0 { |
| 439 | return 0 |
| 440 | } |
| 441 | |
| 442 | pathLen := len(path) |
| 443 | |
| 444 | for _, split := range t.SplitPath { |
| 445 | splitLen := len(split) |
| 446 | if splitLen == 0 || splitLen > pathLen { |
| 447 | continue |
| 448 | } |
| 449 | |
| 450 | for i := 0; i <= pathLen-splitLen; i++ { |
| 451 | match := true |
| 452 | for j := range splitLen { |
| 453 | c := path[i+j] |
| 454 | if c >= utf8.RuneSelf { |
| 455 | match = false |
| 456 | |
| 457 | break |
| 458 | } |
| 459 | |
| 460 | if 'A' <= c && c <= 'Z' { |
| 461 | c += 'a' - 'A' |
| 462 | } |
| 463 | |
| 464 | if c != split[j] { |
| 465 | match = false |
| 466 | |
| 467 | break |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | if match { |
| 472 | return i + splitLen |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | return -1 |
| 478 | } |
| 479 | |
| 480 | type envVars map[string]string |
| 481 |
no outgoing calls