mirror of https://github.com/Xhofe/alist
22 lines
322 B
Go
22 lines
322 B
Go
package utils
|
|
|
|
import (
|
|
"net/url"
|
|
)
|
|
|
|
func InjectQuery(raw string, query url.Values) (string, error) {
|
|
param := query.Encode()
|
|
if param == "" {
|
|
return raw, nil
|
|
}
|
|
u, err := url.Parse(raw)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
joiner := "?"
|
|
if u.RawQuery != "" {
|
|
joiner = "&"
|
|
}
|
|
return raw + joiner + param, nil
|
|
}
|