(first: string, second: string)
| 499 | }) |
| 500 | |
| 501 | const joinSegments = (first: string, second: string): string => { |
| 502 | const endsWithSlash = first.endsWith("/") |
| 503 | const startsWithSlash = second.startsWith("/") |
| 504 | const needsTrim = endsWithSlash && startsWithSlash |
| 505 | const needsSlash = !endsWithSlash && !startsWithSlash |
| 506 | return needsTrim ? |
| 507 | first + second.slice(1) : |
| 508 | needsSlash ? |
| 509 | first + "/" + second : |
| 510 | first + second |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * Updates the request URL by applying a function to the current URL string. |