Redacts sensitive parts of JDBC/OceanBase/SQLServer connection strings.
// Source: https://github.com/t8y2/dbx | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { isSecretConnectionProperty, redactJdbcProperties, redactSqlServerQuery } from "@/lib/connection/jdbcProperties";
/** Shared by copyable connection strings and sidebar previews. */
export function redactConnectionStringSecrets(value: string): string {
// Password-only userinfo (for example redis://:password@host) is valid too.
const redactedOceanBase = value.replace(/^(oceanbase:\/\/[^/\s:?#]*):([^\s/?#]+)@/i, "$1:***@");
const withoutUserInfo = redactedOceanBase.replace(/(:\/\/[^/\s:@?#;]*):([^@\s/?#;]+)@/g, "$1:***@");
const properties = withoutUserInfo.match(/^(jdbc:sqlserver
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key