MCPcopy
hub / github.com/apache/devlake / GetURIStringPointer

Function GetURIStringPointer

backend/helpers/pluginhelper/api/api_client.go:457–483  ·  view source on GitHub ↗

GetURIStringPointer FIXME ...

(baseUrl string, relativePath string, query url.Values)

Source from the content-addressed store, hash-verified

455
456// GetURIStringPointer FIXME ...
457func GetURIStringPointer(baseUrl string, relativePath string, query url.Values) (*string, errors.Error) {
458 // If the base URL doesn't end with a slash, and has a relative path attached
459 // the values will be removed by the Go package, therefore we need to add a missing slash.
460 AddMissingSlashToURL(&baseUrl)
461 base, err := url.Parse(baseUrl)
462 if err != nil {
463 return nil, errors.Convert(err)
464 }
465 // If the relative path starts with a '/', we need to remove it or the values will be removed by the Go package.
466 relativePath = RemoveStartingSlashFromPath(relativePath)
467 u, err := url.Parse(relativePath)
468 if err != nil {
469 return nil, errors.Convert(err)
470 }
471 if query != nil {
472 queryString := u.Query()
473 for key, values := range query {
474 for _, v := range values {
475 queryString.Add(key, v)
476 }
477 }
478
479 u.RawQuery = queryString.Encode()
480 }
481 uri := base.ResolveReference(u).String()
482 return &uri, nil
483}
484
485// AddMissingSlashToURL FIXME ...
486func AddMissingSlashToURL(baseUrl *string) {

Callers 1

DoMethod · 0.85

Calls 6

AddMissingSlashToURLFunction · 0.85
QueryMethod · 0.80
ConvertMethod · 0.45
AddMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected