make SplitBy function public

Signed-off-by: kim (grufwub) <grufwub@gmail.com>
development
kim (grufwub) 4 years ago
parent 55b5bd86a6
commit 52a75eacec

@ -190,7 +190,7 @@ func remapRequestEnabled(request *Request) bool {
}
// Split to new path and paramters again
path, params := splitBy(string(raw), "?")
path, params := SplitBy(string(raw), "?")
// Remap request, log, return
request.Remap(path, params)

@ -21,7 +21,7 @@ func ParseURLEncodedRequest(received string) (*Request, Error) {
}
// Split into 2 substrings by '?'. URL path and query
rawPath, params := splitBy(received, "?")
rawPath, params := SplitBy(received, "?")
// Unescape path
rawPath, err := url.PathUnescape(rawPath)
@ -35,7 +35,7 @@ func ParseURLEncodedRequest(received string) (*Request, Error) {
// ParseInternalRequest parses an internal request string based on the current directory
func ParseInternalRequest(p *Path, line string) *Request {
rawPath, params := splitBy(line, "?")
rawPath, params := SplitBy(line, "?")
if path.IsAbs(rawPath) {
return &Request{getRequestPath(rawPath), params}
}
@ -46,7 +46,7 @@ func ParseInternalRequest(p *Path, line string) *Request {
func getRequestPathUserDirEnabled(rawPath string) *Path {
if userPath := strings.TrimPrefix(rawPath, "/"); strings.HasPrefix(userPath, "~") {
// We found a user path! Split into the user part, and remaining path
user, remaining := splitBy(userPath, "/")
user, remaining := SplitBy(userPath, "/")
// Empty user, we been duped! Return server root
if len(user) <= 1 {

@ -13,7 +13,7 @@ func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() }
func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// SplitBy takes an input string and a delimiter, returning the resulting two strings from the split (ALWAYS 2)
func splitBy(input, delim string) (string, string) {
func SplitBy(input, delim string) (string, string) {
split := strings.SplitN(input, delim, 2)
if len(split) == 2 {
return split[0], split[1]

Loading…
Cancel
Save