mirror of
https://github.com/harness/drone.git
synced 2025-05-06 03:30:20 +08:00
26 lines
437 B
Go
26 lines
437 B
Go
package request
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
|
|
"github.com/go-chi/chi"
|
|
)
|
|
|
|
const (
|
|
RepoRefParamName = "rref"
|
|
)
|
|
|
|
func GetRepoRef(r *http.Request) (string, error) {
|
|
rawRef := chi.URLParam(r, RepoRefParamName)
|
|
if rawRef == "" {
|
|
return "", errors.New("Repository ref parameter not found in request.")
|
|
}
|
|
|
|
// fqns are unescaped and lower
|
|
ref, err := url.PathUnescape(rawRef)
|
|
return strings.ToLower(ref), err
|
|
}
|