strip-url-auth is a focused JavaScript utility that removes the username and password (authentication) portion from a given URL string. It is currently stable at version 2.0.0. Developed by Sindresorhus, it adheres to a philosophy of single-purpose, highly reliable modules. Key differentiators include its minimalistic API, robust parsing for common URL formats, and its strict adherence to modern JavaScript standards. Releases typically occur when necessary for compatibility with newer Node.js versions or to address specific edge cases, rather than on a fixed cadence. It provides a simple, direct solution for sanitizing URLs for display or storage where authentication credentials should not be exposed.
npm install strip-url-authVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to import and use `stripUrlAuth` to remove authentication credentials from various URL formats, including HTTPS and FTP, and shows its behavior with URLs that do not contain auth or have malformed auth segments.
Migrate your project to use ES Modules or use dynamic `import()` where necessary. Ensure your `package.json` has `"type": "module"` or use `.mjs` file extension for modules importing this package.
Upgrade your Node.js runtime to version 12 or newer. If you cannot upgrade Node.js, you must remain on `strip-url-auth` v1.x.
For comprehensive URL validation or other manipulations (e.g., encoding components), combine this package with a dedicated URL parsing library like Node's built-in `URL` class or a third-party module like `url-parse`.
Change `const stripUrlAuth = require('strip-url-auth');` to `import stripUrlAuth from 'strip-url-auth';` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` file extensions).Ensure your project or file is treated as an ES Module by adding `"type": "module"` to your `package.json` or by changing the file extension to `.mjs`. Alternatively, if you must remain in CommonJS, consider dynamic import: `(async () => { const { default: stripUrlAuth } = await import('strip-url-auth'); /* use stripUrlAuth */ })();` or stick to v1.x of the package.No dependency data recorded yet.