mirror of
https://github.com/harness/drone.git
synced 2025-05-06 00:49:45 +08:00

Add enforcement of the path length to the store layer before writing the path, move errs to internal, and adds a comms package under internal/api.
26 lines
447 B
Go
26 lines
447 B
Go
package request
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
|
|
"github.com/go-chi/chi"
|
|
"github.com/harness/gitness/internal/errs"
|
|
)
|
|
|
|
const (
|
|
RepoRefParamName = "rref"
|
|
)
|
|
|
|
func GetRepoRef(r *http.Request) (string, error) {
|
|
rawRef := chi.URLParam(r, RepoRefParamName)
|
|
if rawRef == "" {
|
|
return "", errs.RepoReferenceNotFoundInRequest
|
|
}
|
|
|
|
// paths are unescaped and lower
|
|
ref, err := url.PathUnescape(rawRef)
|
|
return strings.ToLower(ref), err
|
|
}
|