Skip to content

Commit aa6d88b

Browse files
committed
refactor(deps): replace url-parse with native URL API
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 #106
1 parent 1898747 commit aa6d88b

File tree

3 files changed

+422
-352
lines changed

3 files changed

+422
-352
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@
6363
"path-to-regexp": "^6.2.1",
6464
"pino": "8.11.0",
6565
"pino-pretty": "10.2.0",
66-
"require-in-the-middle": "^5.1.0",
67-
"url-parse": "^1.5.10"
66+
"require-in-the-middle": "^5.1.0"
6867
},
6968
"devDependencies": {
7069
"@ava/typescript": "^1.1.1",
@@ -74,7 +73,6 @@
7473
"@types/express": "^4.17.9",
7574
"@types/lodash": "^4.14.166",
7675
"@types/node": "^14.14.14",
77-
"@types/url-parse": "^1.4.11",
7876
"@typescript-eslint/eslint-plugin": "^4.0.1",
7977
"@typescript-eslint/parser": "^4.0.1",
8078
"ava": "^3.12.1",

src/enforcement/enforcer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import axios, { AxiosInstance } from 'axios';
22
import { Logger } from 'pino';
3-
import URL from 'url-parse';
43

54
import { IPermitConfig } from '../config';
65
import { CheckConfig, Context, ContextStore } from '../utils/context';
@@ -134,8 +133,8 @@ export class Enforcer implements IEnforcer {
134133
*/
135134
constructor(private config: IPermitConfig, private logger: Logger) {
136135
const opaBaseUrl = new URL(this.config.pdp);
137-
opaBaseUrl.set('port', '8181');
138-
opaBaseUrl.set('pathname', `${opaBaseUrl.pathname}v1/data/permit/`);
136+
opaBaseUrl.port = '8181';
137+
opaBaseUrl.pathname = `${opaBaseUrl.pathname}v1/data/permit/`;
139138
const version = process.env.npm_package_version ?? 'unknown';
140139
if (config.axiosInstance) {
141140
this.client = config.axiosInstance;

0 commit comments

Comments
 (0)