1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-01 08:03:26 +00:00

Move dircache, oauthutil, rest and pacer modules into lib

This commit is contained in:
Nick Craig-Wood
2018-01-11 16:29:20 +00:00
parent b8b620f5c2
commit 60afda007b
30 changed files with 35 additions and 35 deletions

27
lib/rest/url.go Normal file
View File

@@ -0,0 +1,27 @@
package rest
import (
"net/url"
"github.com/pkg/errors"
)
// URLJoin joins a URL and a path returning a new URL
//
// path should be URL escaped
func URLJoin(base *url.URL, path string) (*url.URL, error) {
rel, err := url.Parse(path)
if err != nil {
return nil, errors.Wrapf(err, "Error parsing %q as URL", path)
}
return base.ResolveReference(rel), nil
}
// URLPathEscape escapes URL path the in string using URL escaping rules
//
// This mimics url.PathEscape which only available from go 1.8
func URLPathEscape(in string) string {
var u url.URL
u.Path = in
return u.String()
}