mirror of https://github.com/matrix-org/gomatrix
Merge pull request #61 from matrix-org/babolivier/trailing-slashes
Manually append a trailing slash at the end of a path if needed
This commit is contained in:
commit
54b415d5fa
|
@ -13,6 +13,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -68,6 +69,10 @@ func (cli *Client) BuildBaseURL(urlPath ...string) string {
|
||||||
parts := []string{hsURL.Path}
|
parts := []string{hsURL.Path}
|
||||||
parts = append(parts, urlPath...)
|
parts = append(parts, urlPath...)
|
||||||
hsURL.Path = path.Join(parts...)
|
hsURL.Path = path.Join(parts...)
|
||||||
|
// Manually add the trailing slash back to the end of the path if it's explicitely needed
|
||||||
|
if strings.HasSuffix(urlPath[len(urlPath)-1], "/") {
|
||||||
|
hsURL.Path = hsURL.Path + "/"
|
||||||
|
}
|
||||||
query := hsURL.Query()
|
query := hsURL.Query()
|
||||||
if cli.AccessToken != "" {
|
if cli.AccessToken != "" {
|
||||||
query.Set("access_token", cli.AccessToken)
|
query.Set("access_token", cli.AccessToken)
|
||||||
|
|
Loading…
Reference in New Issue