feat(oonirun): add support for OONIRun v2 links (#844)
This diff adds support for OONIRun v2 links. Part of https://github.com/ooni/probe/issues/2184.
This commit is contained in:
parent
ebb78c2848
commit
9a0153a349
11 changed files with 644 additions and 22 deletions
|
|
@ -148,21 +148,19 @@ func (c *apiClient) newRequestWithJSONBody(
|
|||
return request, nil
|
||||
}
|
||||
|
||||
// joinURLPath appends the path of resource URL to the baseURL taking
|
||||
// care of multiple forward slashes gracefully.
|
||||
func (c *apiClient) joinURLPath(origPath string, newPath string) string {
|
||||
|
||||
// If the BaseURL path doesn't end with a slash, added one
|
||||
if !strings.HasSuffix(origPath, "/") {
|
||||
origPath += "/"
|
||||
// joinURLPath appends resourcePath to the urlPath.
|
||||
func (c *apiClient) joinURLPath(urlPath, resourcePath string) string {
|
||||
if resourcePath == "" {
|
||||
if urlPath == "" {
|
||||
return "/"
|
||||
}
|
||||
return urlPath
|
||||
}
|
||||
|
||||
// If the resourceURL path has a leading slash, it is removed
|
||||
if strings.HasPrefix(newPath, "/") {
|
||||
newPath = newPath[1:]
|
||||
if !strings.HasSuffix(urlPath, "/") {
|
||||
urlPath += "/"
|
||||
}
|
||||
|
||||
return origPath + newPath
|
||||
resourcePath = strings.TrimPrefix(resourcePath, "/")
|
||||
return urlPath + resourcePath
|
||||
}
|
||||
|
||||
// newRequest creates a new request.
|
||||
|
|
|
|||
Loading…
Reference in a new issue