{"id":13175,"library":"fast-url-parser","title":"Fast URL Parser","description":"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.","status":"abandoned","version":"1.1.3","language":"javascript","source_language":"en","source_url":"git://github.com/petkaantonov/urlparser","tags":["javascript","fast","parse","parser","url","uri","performance"],"install":[{"cmd":"npm install fast-url-parser","lang":"bash","label":"npm"},{"cmd":"yarn add fast-url-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add fast-url-parser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Optional custom query string parser, not bundled by default but suggested for advanced use cases.","package":"querystringparser","optional":true}],"imports":[{"note":"This package is CommonJS-only and does not support ESM `import` syntax.","wrong":"import url from 'fast-url-parser';","symbol":"url","correct":"const url = require('fast-url-parser');"},{"note":"While named destructuring works for convenience, the module is a single CommonJS export. Direct property access (e.g., `url.parse`) is also common.","wrong":"import { parse } from 'fast-url-parser';","symbol":"url.parse","correct":"const { parse } = require('fast-url-parser');"},{"note":"The `replace` method is called directly on the module export to globally swap the native 'url' module.","wrong":"import { replace } from 'fast-url-parser'; replace();","symbol":"replace","correct":"require('fast-url-parser').replace();"}],"quickstart":{"code":"const url = require('fast-url-parser');\n\n// Optionally inject a custom querystring parser\n// url.queryString = require('querystringparser');\n\nconst fullUrl = '/path?user[name][first]=tj&user[name][last]=holowaychuk#section1';\n\n// Parse a URL\nconst parsed = url.parse(fullUrl, true); // true for query string parsing into object\nconsole.log('Parsed URL:', parsed);\nconsole.log('Protocol:', parsed.protocol); // null\nconsole.log('Hostname:', parsed.hostname); // null\nconsole.log('Pathname:', parsed.pathname); // /path\nconsole.log('Query:', parsed.query); // { user: { name: { first: 'tj', last: 'holowaychuk' } } } if querystringparser is used, otherwise { 'user[name][first]': 'tj', 'user[name][last]': 'holowaychuk' }\nconsole.log('Hash:', parsed.hash); // #section1\n\n// Format a URL\nconst formatted = url.format({\n  protocol: 'http:',\n  host: 'example.com',\n  pathname: '/my/path',\n  query: { id: 123, name: 'test' },\n  hash: 'anchor'\n});\nconsole.log('Formatted URL:', formatted);\n\n// Resolve a URL\nconst resolved = url.resolve('http://example.com/foo/bar', '../baz/qux');\nconsole.log('Resolved URL:', resolved);\n","lang":"javascript","description":"Demonstrates basic URL parsing, formatting, and resolving using `fast-url-parser`, showcasing its API compatibility with Node.js core `url`."},"warnings":[{"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`.","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The 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).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If nested query parameters are expected, set `url.queryString = require(\"querystringparser\")` *before* calling `url.parse()`.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"Attempting to use `require()` syntax in an ECMAScript Module (ESM) file.","error":"require is not defined"},{"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.","cause":"The `fast-url-parser` module was not correctly imported or `url` is not the module export.","error":"TypeError: url.parse is not a function"},{"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.","cause":"Using `require('fast-url-parser').replace()` has globally altered the behavior of `require('url')` for all modules, potentially causing conflicts with other dependencies.","error":"The 'url' module has been replaced globally by 'fast-url-parser' and unexpected behavior is occurring."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}