mirror of
				https://github.com/matrix-org/gomatrix
				synced 2025-11-03 22:08:04 +00:00 
			
		
		
		
	Manually append a trailing slash at the end of a path if needed
This commit is contained in:
		
							parent
							
								
									94881c65f3
								
							
						
					
					
						commit
						998378da2b
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -13,6 +13,7 @@ import (
 | 
			
		|||
	"net/url"
 | 
			
		||||
	"path"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -68,6 +69,10 @@ func (cli *Client) BuildBaseURL(urlPath ...string) string {
 | 
			
		|||
	parts := []string{hsURL.Path}
 | 
			
		||||
	parts = append(parts, urlPath...)
 | 
			
		||||
	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()
 | 
			
		||||
	if cli.AccessToken != "" {
 | 
			
		||||
		query.Set("access_token", cli.AccessToken)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue