17 lines
319 B
Go
17 lines
319 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"path"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// ShiftPath function taken from https://blog.merovius.de/posts/2017-06-18-how-not-to-use-an-http-router/
|
||
|
func ShiftPath(p string) (head, tail string) {
|
||
|
p = path.Clean("/" + p)
|
||
|
i := strings.Index(p[1:], "/") + 1
|
||
|
if i <= 0 {
|
||
|
return p[1:], "/"
|
||
|
}
|
||
|
return p[1:i], p[i:]
|
||
|
}
|