Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/fixer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var { URL } = require('node:url')
var isValidSemver = require('semver/functions/valid')
var cleanSemver = require('semver/functions/clean')
var validateLicense = require('validate-npm-package-license')
var hostedGitInfo = require('hosted-git-info')
var { isBuiltin } = require('node:module')
var depTypes = ['dependencies', 'devDependencies', 'optionalDependencies']
var extractDescription = require('./extract_description')
var url = require('url')
var typos = require('./typos.json')

var isEmail = str => str.includes('@') && (str.indexOf('@') < str.lastIndexOf('.'))
Expand Down Expand Up @@ -269,8 +269,7 @@ module.exports = {
if (typeof data.bugs === 'string') {
if (isEmail(data.bugs)) {
data.bugs = { email: data.bugs }
/* eslint-disable-next-line node/no-deprecated-api */
} else if (url.parse(data.bugs).protocol) {
} else if (URL.canParse(data.bugs)) {
data.bugs = { url: data.bugs }
} else {
this.warn('nonEmailUrlBugsString')
Expand All @@ -280,8 +279,7 @@ module.exports = {
var oldBugs = data.bugs
data.bugs = {}
if (oldBugs.url) {
/* eslint-disable-next-line node/no-deprecated-api */
if (typeof (oldBugs.url) === 'string' && url.parse(oldBugs.url).protocol) {
if (URL.canParse(oldBugs.url)) {
data.bugs.url = oldBugs.url
} else {
this.warn('nonUrlBugsUrlField')
Expand Down Expand Up @@ -317,8 +315,7 @@ module.exports = {
this.warn('nonUrlHomepage')
return delete data.homepage
}
/* eslint-disable-next-line node/no-deprecated-api */
if (!url.parse(data.homepage).protocol) {
if (!URL.canParse(data.homepage)) {
data.homepage = 'http://' + data.homepage
}
},
Expand Down
Loading