longestCommonPrefix returns the length of the shared prefix between a and b.
(a, b string)
| 273 | |
| 274 | // longestCommonPrefix returns the length of the shared prefix between a and b. |
| 275 | func longestCommonPrefix(a, b string) int { |
| 276 | max := len(a) |
| 277 | if len(b) < max { |
| 278 | max = len(b) |
| 279 | } |
| 280 | for i := 0; i < max; i++ { |
| 281 | if a[i] != b[i] { |
| 282 | return i |
| 283 | } |
| 284 | } |
| 285 | return max |
| 286 | } |
| 287 | |
| 288 | // buildParams zips paramNames with captured values into a map. |
| 289 | func buildParams(names, values []string) map[string]string { |