forked from forgejo/forgejo
Populate URL field of API commits (#3546)
* Populate URL field of API commits * fix orgmode_test
This commit is contained in:
parent
7b297808ce
commit
7b104f0cd0
11 changed files with 126 additions and 98 deletions
|
@ -4,6 +4,13 @@
|
|||
|
||||
package util
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// OptionalBool a boolean that can be "null"
|
||||
type OptionalBool byte
|
||||
|
||||
|
@ -47,6 +54,20 @@ func Max(a, b int) int {
|
|||
return a
|
||||
}
|
||||
|
||||
// URLJoin joins url components, like path.Join, but preserving contents
|
||||
func URLJoin(base string, elems ...string) string {
|
||||
u, err := url.Parse(base)
|
||||
if err != nil {
|
||||
log.Error(4, "URLJoin: Invalid base URL %s", base)
|
||||
return ""
|
||||
}
|
||||
joinArgs := make([]string, 0, len(elems)+1)
|
||||
joinArgs = append(joinArgs, u.Path)
|
||||
joinArgs = append(joinArgs, elems...)
|
||||
u.Path = path.Join(joinArgs...)
|
||||
return u.String()
|
||||
}
|
||||
|
||||
// Min min of two ints
|
||||
func Min(a, b int) int {
|
||||
if a > b {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue