MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / createGitCloneUrlWithToken

Function createGitCloneUrlWithToken

packages/backend/src/utils.ts:248–262  ·  view source on GitHub ↗
(cloneUrl: string, credentials: { username?: string, password: string })

Source from the content-addressed store, hash-verified

246}
247
248const createGitCloneUrlWithToken = (cloneUrl: string, credentials: { username?: string, password: string }) => {
249 const url = new URL(cloneUrl);
250 // @note: URL has a weird behavior where if you set the password but
251 // _not_ the username, the ":" delimiter will still be present in the
252 // URL (e.g., https://:password@example.com). To get around this, if
253 // we only have a password, we set the username to the password.
254 // @see: https://www.typescriptlang.org/play/?#code/MYewdgzgLgBArgJwDYwLwzAUwO4wKoBKAMgBQBEAFlFAA4QBcA9I5gB4CGAtjUpgHShOZADQBKANwAoREj412ECNhAIAJmhhl5i5WrJTQkELz5IQAcxIy+UEAGUoCAJZhLo0UA
255 if (!credentials.username) {
256 url.username = credentials.password;
257 } else {
258 url.username = credentials.username;
259 url.password = credentials.password;
260 }
261 return url.toString();
262}
263
264
265// setInterval wrapper that ensures async callbacks are not executed concurrently.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected