Created
March 7, 2024 15:08
-
-
Save christophemarois/78f9245253bd8cfed2b96203eb3a9fc9 to your computer and use it in GitHub Desktop.
redactPasswordFromUrl.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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