Registry / http-networking / fast-url-parser

fast-url-parser

JSON →
library1.1.3jsnpmunverified

fast-url-parser is an extremely fast implementation of Node.js's core `url` module, providing a compatible API for parsing, formatting, and resolving URLs. Its current stable version is 1.1.3. The package was last updated in 2014 and appears to be abandoned, with no active release cadence. Its primary differentiator at the time of its release was significantly higher performance compared to Node's built-in `url` module. It also offers the ability to inject a custom query string parser and includes a global `replace()` method to swap out Node.js's native `url` module with this faster alternative across an entire application. This package is exclusively CommonJS and does not support modern ECMAScript Modules (ESM) directly.

npm install fast-url-parser
INSTALL
IMPORT
SIG · FAST-URL-PARSER
F
fast-url-parser
http-networkingjavascriptv1.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

url
const url = require('fast-url-parser');
import url from 'fast-url-parser';
This package is CommonJS-only and does not support ESM `import` syntax.
url.parse
const { parse } = require('fast-url-parser');
import { parse } from 'fast-url-parser';
While named destructuring works for convenience, the module is a single CommonJS export. Direct property access (e.g., `url.parse`) is also common.
replace
require('fast-url-parser').replace();
import { replace } from 'fast-url-parser'; replace();
The `replace` method is called directly on the module export to globally swap the native 'url' module.

Demonstrates basic URL parsing, formatting, and resolving using `fast-url-parser`, showcasing its API compatibility with Node.js core `url`.

const url = require('fast-url-parser'); // Optionally inject a custom querystring parser // url.queryString = require('querystringparser'); const fullUrl = '/path?user[name][first]=tj&user[name][last]=holowaychuk#section1'; // Parse a URL const parsed = url.parse(fullUrl, true); // true for query string parsing into object console.log('Parsed URL:', parsed); console.log('Protocol:', parsed.protocol); // null console.log('Hostname:', parsed.hostname); // null console.log('Pathname:', parsed.pathname); // /path console.log('Query:', parsed.query); // { user: { name: { first: 'tj', last: 'holowaychuk' } } } if querystringparser is used, otherwise { 'user[name][first]': 'tj', 'user[name][last]': 'holowaychuk' } console.log('Hash:', parsed.hash); // #section1 // Format a URL const formatted = url.format({ protocol: 'http:', host: 'example.com', pathname: '/my/path', query: { id: 123, name: 'test' }, hash: 'anchor' }); console.log('Formatted URL:', formatted); // Resolve a URL const resolved = url.resolve('http://example.com/foo/bar', '../baz/qux'); console.log('Resolved URL:', resolved);
Debug
Known issues
breakingThis package is abandoned and has not been updated since 2014. It may contain unpatched security vulnerabilities related to URL parsing or be incompatible with newer Node.js versions and web standards (RFCs). Using it in production is highly discouraged.
fix
Migrate to Node.js's built-in `URL` global object (if targeting Node.js >= 10) or a well-maintained, modern URL parsing library like `whatwg-url` or `url-parse`.
affects: >=1.0.0
gotchaThe `require("fast-url-parser").replace()` method globally swaps Node.js's built-in `url` module with this package. This is a major side effect that can lead to unexpected behavior in other parts of your application or dependencies that rely on the native `url` module's specific quirks or updates.
fix
Avoid using `replace()`. If you need to use `fast-url-parser`, import it directly and use its functions explicitly. For modern applications, prefer the native `URL` global object.
affects: >=1.0.0
gotchaThe package is CommonJS-only (`require`). Attempting to `import` it in an ESM module will result in an error or require specific build tool configurations (e.g., Babel, Webpack).
fix
Ensure your project is configured for CommonJS, or use dynamic `import()` for ESM contexts if absolutely necessary, though migrating to a modern ESM-compatible alternative is recommended.
affects: >=1.0.0
gotchaThe default querystring parser is Node's core 'querystring' module. If you pass `true` as the second argument to `url.parse()` to parse the query string into an object, and require nested objects, you MUST explicitly set `url.queryString = require("querystringparser")` as shown in the README, otherwise you will get a flat object.
fix
If nested query parameters are expected, set `url.queryString = require("querystringparser")` *before* calling `url.parse()`.
affects: >=1.0.0
Errors
Common errors & fixes
require is not defined
Attempting to use `require()` syntax in an ECMAScript Module (ESM) file.
fix
Rename your file to `.cjs` or set `"type": "commonjs"` in your `package.json`. Alternatively, use `import()` dynamically if your environment supports it, or switch to an ESM-compatible URL parser.
TypeError: url.parse is not a function
The `fast-url-parser` module was not correctly imported or `url` is not the module export.
fix
Ensure `const url = require('fast-url-parser');` is at the top of your file and `url` is not being shadowed or reassigned. Verify the package is installed.
The 'url' module has been replaced globally by 'fast-url-parser' and unexpected behavior is occurring.
Using `require('fast-url-parser').replace()` has globally altered the behavior of `require('url')` for all modules, potentially causing conflicts with other dependencies.
fix
Remove the call to `require('fast-url-parser').replace()`. Instead, import `fast-url-parser` explicitly (`const fastUrl = require('fast-url-parser');`) and use its functions directly. Evaluate migrating to the native `URL` global.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
querystringparseroptionalOptional custom query string parser, not bundled by default but suggested for advanced use cases.
Agent activity
2 hits · last 30 days
node
2
Resources
fast-url-parser — npm install fast-url-parser · libregistry