Skip to content

Instantly share code, notes, and snippets.

@christophemarois
Created March 7, 2024 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophemarois/78f9245253bd8cfed2b96203eb3a9fc9 to your computer and use it in GitHub Desktop.
Save christophemarois/78f9245253bd8cfed2b96203eb3a9fc9 to your computer and use it in GitHub Desktop.
redactPasswordFromUrl.ts
/** Transform the password part of a connection string URL into [redacted].
* Useful for logging. */
export function redactPasswordFromUrl(url: string) {
return url.replace(/^([^:]+):\/\/([^:]*):([^@]+)@/, '$1://$2:[redacted]@')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment