url-parse-as-address is a JavaScript utility for parsing URL strings, specifically designed to assume the `http` protocol if no scheme or leading `//` is explicitly provided. This behavior mimics how web browsers handle incomplete URL inputs, making it suitable for scenarios where user-entered addresses might lack full protocol specification (e.g., 'foo.com' instead of 'http://foo.com'). Published as version 1.0.0 over a decade ago, this package primarily functions as a CommonJS module. It provides a parsed object structure similar to Node.js's legacy `url.parse()` method, including properties like `protocol`, `host`, `pathname`, and `query`. Due to its age and lack of updates, newer projects are generally advised to use the WHATWG `URL` API (built into Node.js and modern browsers) or more actively maintained alternatives that offer better security, features, and ESM support, especially given its limited ecosystem adoption (17 dependents).
npm install url-parse-as-addressVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic URL parsing with `url-parse-as-address`, showing how it defaults to `http:` protocol and how to optionally parse query strings into an object.
Migrate to Node.js's built-in `URL` class (WHATWG URL API) or a well-maintained third-party library like `url-parse` or `parseuri` for robust and secure URL handling. Example: `new URL('http://foo.com')` or `new URL('foo.com', 'http://base.com')`.Use `const parse = require('url-parse-as-address');` for CommonJS environments. In an ESM context, you may need to use `createRequire` from `node:module` or dynamic `import()` if you absolutely must use this package, but migration is strongly recommended.Understand this specific parsing behavior and ensure it aligns with your application's requirements. If strict adherence to WHATWG URL parsing is needed, use the native `URL` class or alternatives that implement it.
This package is CommonJS-only. If your project is ESM, either convert the file to CommonJS (`.cjs` or `"type": "commonjs"` in `package.json`) or use `import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);` to create a `require` function in ESM. It's better to migrate away from this package.Use `const parse = require('url-parse-as-address');` as the package exports its main function as the `module.exports` object. It does not have named exports for `parse` or `format` in the ESM sense.No dependency data recorded yet.