Skip to content

refactor(deps): replace url-parse with native URL API#122

Open
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Kyzgor:fix/106-remove-url-parse-dependency
Open

refactor(deps): replace url-parse with native URL API#122
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Kyzgor:fix/106-remove-url-parse-dependency

Conversation

@Kyzgor
Copy link

@Kyzgor Kyzgor commented Mar 8, 2026

Summary

Remove the url-parse dependency in favor of the native URL class, which has been available since Node.js v10 — the SDK's minimum supported version.

Problem

As reported in #106, url-parse is an unnecessary third-party dependency. Node.js natively supports the URL class since v10, making this package redundant and adding unnecessary weight to the bundle.

Solution

Replaced all url-parse usage in src/enforcement/enforcer.ts with the native URL API:

  • opaBaseUrl.set('port', '8181')opaBaseUrl.port = '8181'
  • opaBaseUrl.set('pathname', ...)opaBaseUrl.pathname = ...
  • .toString() — works identically on both

Changes

  • src/enforcement/enforcer.ts — Removed url-parse import, replaced .set() calls with native property assignment
  • package.json — Removed url-parse from dependencies and @types/url-parse from devDependencies
  • yarn.lock — Regenerated without url-parse

Testing

  • yarn lint — passes (0 errors)
  • yarn build — succeeds (both CJS and ESM)
  • yarn test:module-imports — all 9 tests pass
  • Manual CJS verification: node -e "const { Permit } = require('./build'); console.log(typeof Permit);"function

Backwards Compatibility

No breaking changes. Fully backwards-compatible. The native URL API has identical behavior for the operations used (constructor, port/pathname assignment, toString).

Checklist

  • yarn lint passes
  • yarn build succeeds (both CJS and ESM)
  • yarn test:module-imports passes
  • No changes to src/openapi/ (auto-generated)

Fixes #106

Remove the `url-parse` dependency in favor of the native `URL` class,
which has been available since Node.js v10 (the SDK's minimum supported
version). This eliminates an unnecessary dependency and reduces bundle
size.

Fixes permitio#106
@Kyzgor Kyzgor force-pushed the fix/106-remove-url-parse-dependency branch from 0053425 to aa6d88b Compare March 8, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

url-parser is an unnecessary dependency

1 participant