(u string)
| 356 | } |
| 357 | |
| 358 | func Dir(u string) string { |
| 359 | // 安全的获取目录, 不会额外处理多个"//", 并非用来获取上级目录 |
| 360 | // /a / |
| 361 | // /a/ /a/ |
| 362 | // a/ a/ |
| 363 | // aaa / |
| 364 | if strings.HasSuffix(u, "/") { |
| 365 | return u |
| 366 | } else if i := strings.LastIndex(u, "/"); i == -1 { |
| 367 | return "/" |
| 368 | } else { |
| 369 | return u[:i+1] |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | func FormatURL(base, u string) string { |
| 374 | if strings.HasPrefix(u, "http") { |
no outgoing calls
no test coverage detected