MCPcopy Index your code
hub / github.com/apache/devlake / replaceAcessTokenInUrl

Function replaceAcessTokenInUrl

backend/plugins/github/impl/impl.go:347–366  ·  view source on GitHub ↗
(gitURL, newCredential string)

Source from the content-addressed store, hash-verified

345}
346
347func replaceAcessTokenInUrl(gitURL, newCredential string) (string, errors.Error) {
348 atIndex := strings.Index(gitURL, "@")
349 if atIndex == -1 {
350 return "", errors.Default.New("Invalid Git URL")
351 }
352
353 protocolIndex := strings.Index(gitURL, "://")
354 if protocolIndex == -1 {
355 return "", errors.Default.New("Invalid Git URL")
356 }
357
358 // Extract the base URL (e.g., "https://git:")
359 baseURL := gitURL[:protocolIndex+7]
360
361 repoURL := gitURL[atIndex+1:]
362
363 modifiedURL := fmt.Sprintf("%s%s@%s", baseURL, newCredential, repoURL)
364
365 return modifiedURL, nil
366}

Callers 1

GetDynamicGitUrlMethod · 0.85

Calls 1

NewMethod · 0.65

Tested by

no test coverage detected