Skip to content

Commit 26419a3

Browse files
committed
fix: use URL.canParse instead of runtime deprecated url.parse api
1 parent cc37f25 commit 26419a3

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

lib/fixer.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ var hostedGitInfo = require('hosted-git-info')
55
var { isBuiltin } = require('node:module')
66
var depTypes = ['dependencies', 'devDependencies', 'optionalDependencies']
77
var extractDescription = require('./extract_description')
8-
var url = require('url')
98
var typos = require('./typos.json')
109

1110
var isEmail = str => str.includes('@') && (str.indexOf('@') < str.lastIndexOf('.'))
@@ -269,8 +268,7 @@ module.exports = {
269268
if (typeof data.bugs === 'string') {
270269
if (isEmail(data.bugs)) {
271270
data.bugs = { email: data.bugs }
272-
/* eslint-disable-next-line node/no-deprecated-api */
273-
} else if (url.parse(data.bugs).protocol) {
271+
} else if (URL.canParse(data.bugs)) {
274272
data.bugs = { url: data.bugs }
275273
} else {
276274
this.warn('nonEmailUrlBugsString')
@@ -280,8 +278,7 @@ module.exports = {
280278
var oldBugs = data.bugs
281279
data.bugs = {}
282280
if (oldBugs.url) {
283-
/* eslint-disable-next-line node/no-deprecated-api */
284-
if (typeof (oldBugs.url) === 'string' && url.parse(oldBugs.url).protocol) {
281+
if (URL.canParse(oldBugs.url)) {
285282
data.bugs.url = oldBugs.url
286283
} else {
287284
this.warn('nonUrlBugsUrlField')
@@ -317,8 +314,7 @@ module.exports = {
317314
this.warn('nonUrlHomepage')
318315
return delete data.homepage
319316
}
320-
/* eslint-disable-next-line node/no-deprecated-api */
321-
if (!url.parse(data.homepage).protocol) {
317+
if (!URL.canParse(data.homepage)) {
322318
data.homepage = 'http://' + data.homepage
323319
}
324320
},

0 commit comments

Comments
 (0)