Skip to content

Commit b313fda

Browse files
committed
refactor: replace url module with URL constructor in parseURL function
1 parent 96920a8 commit b313fda

3 files changed

Lines changed: 11 additions & 135 deletions

File tree

lib/helpers.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import chalk from 'chalk';
22
import readlineSync from 'readline-sync';
3-
import url from 'url';
43
import APIs from './paystack/apis.js';
54
import axios from 'axios';
65
import progressBar from 'progressbar';
@@ -52,8 +51,17 @@ export function infoLog(error) {
5251
}
5352

5453
export function parseURL(uri) {
55-
if (!uri.startsWith('http')) uri = 'http://' + uri;
56-
return url.parse(uri);
54+
if (!uri.startsWith('http://') && !uri.startsWith('https://')) {
55+
uri = 'http://' + uri;
56+
}
57+
const parsed = new URL(uri);
58+
return {
59+
protocol: parsed.protocol,
60+
hostname: parsed.hostname,
61+
port: parsed.port || '',
62+
pathname: parsed.pathname,
63+
search: parsed.search,
64+
};
5765
}
5866

5967
export function findSchema(command, args) {

package-lock.json

Lines changed: 0 additions & 131 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"progressbar": "^1.3.0",
1919
"readline-sync": "^1.4.10",
2020
"shelljs": "^0.8.5",
21-
"url": "^0.11.0",
2221
"vorpal": "^1.12.0"
2322
},
2423
"overrides": {

0 commit comments

Comments
 (0)