mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-10 19:15:54 +00:00
`util.URLJoin` was deprecated with unclear semantics (path normalization via `url.Parse`/`ResolveReference` that surprised callers). This removes it entirely and replaces all usages with straightforward `"/"` string concatenation. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
29 lines
589 B
Go
29 lines
589 B
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package util
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// PathEscapeSegments escapes segments of a path while not escaping forward slash
|
|
func PathEscapeSegments(path string) string {
|
|
slice := strings.Split(path, "/")
|
|
for index := range slice {
|
|
slice[index] = url.PathEscape(slice[index])
|
|
}
|
|
escapedPath := strings.Join(slice, "/")
|
|
return escapedPath
|
|
}
|
|
|
|
func SanitizeURL(s string) (string, error) {
|
|
u, err := url.Parse(s)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
u.User = nil
|
|
return u.String(), nil
|
|
}
|