{"library":"redact-basic-auth","title":"Redact Basic Auth","description":"redact-basic-auth is a focused utility designed to remove or obscure basic authentication credentials from URLs. This is crucial for logging, debugging, or displaying URLs where sensitive information like usernames and passwords should not be exposed. The package is currently at version 1.0.1, indicating a stable and mature, albeit simple, implementation. Its release cadence is likely very slow, as its functionality is narrowly defined and unlikely to require frequent updates. Key differentiators include its singular focus and minimal API, making it easy to integrate without pulling in larger URL parsing libraries when only basic auth redaction is needed. It operates on string manipulation rather than full URL parsing objects, providing a lightweight solution for specific security and privacy concerns in applications that handle URLs.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install redact-basic-auth"],"cli":{"name":"redact-basic-auth","version":null}},"imports":["const redact = require('redact-basic-auth');","import redact from 'redact-basic-auth';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import redact from 'redact-basic-auth';\n\n// Example 1: Redacting a URL with basic authentication\nconst urlWithAuth = 'http://myuser:mypassword@example.com/api/data?param=value';\nconst redactedUrl = redact(urlWithAuth);\nconsole.log('Original URL:', urlWithAuth);\nconsole.log('Redacted URL:', redactedUrl);\n// Expected: Original URL: http://myuser:mypassword@example.com/api/data?param=value\n// Expected: Redacted URL: http://myuser:redacted@example.com/api/data?param=value\n\n// Example 2: A URL without basic authentication remains unchanged\nconst urlWithoutAuth = 'https://www.google.com/search?q=redact-basic-auth';\nconst unchangedUrl = redact(urlWithoutAuth);\nconsole.log('Original URL (no auth):', urlWithoutAuth);\nconsole.log('Unchanged URL:', unchangedUrl);\n// Expected: Original URL (no auth): https://www.google.com/search?q=redact-basic-auth\n// Expected: Unchanged URL: https://www.google.com/search?q=redact-basic-auth\n\n// Example 3: Using with a Node.js URL object (convert to string first)\nimport { URL } from 'url';\nconst complexUrl = new URL('ftp://anonymous:secret@ftp.example.org/files/doc.txt');\nconst redactedComplexUrl = redact(complexUrl.toString());\nconsole.log('Original complex URL:', complexUrl.toString());\nconsole.log('Redacted complex URL:', redactedComplexUrl);","lang":"javascript","description":"Demonstrates basic authentication redaction for various URL formats, including those with and without credentials, and how to use it with Node.js URL objects.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}