1
1
// Originally normalize-package-data
2
2
3
- const url = require ( 'node:url' )
4
3
const hostedGitInfo = require ( 'hosted-git-info' )
5
4
const validateLicense = require ( 'validate-npm-package-license' )
6
5
@@ -124,7 +123,7 @@ function normalizeData (data, changes) {
124
123
if ( isEmail ( data . bugs ) ) {
125
124
data . bugs = { email : data . bugs }
126
125
/* eslint-disable-next-line node/no-deprecated-api */
127
- } else if ( url . parse ( data . bugs ) . protocol ) {
126
+ } else if ( URL . canParse ( data . bugs ) ) {
128
127
data . bugs = { url : data . bugs }
129
128
} else {
130
129
changes ?. push ( `Bug string field must be url, email, or {email,url}` )
@@ -141,7 +140,7 @@ function normalizeData (data, changes) {
141
140
data . bugs = { }
142
141
if ( oldBugs . url ) {
143
142
/* eslint-disable-next-line node/no-deprecated-api */
144
- if ( typeof ( oldBugs . url ) === 'string' && url . parse ( oldBugs . url ) . protocol ) {
143
+ if ( typeof ( oldBugs . url ) === 'string' && URL . canParse ( oldBugs . url ) ) {
145
144
data . bugs . url = oldBugs . url
146
145
} else {
147
146
changes ?. push ( 'bugs.url field must be a string url. Deleted.' )
@@ -217,7 +216,7 @@ function normalizeData (data, changes) {
217
216
delete data . homepage
218
217
} else {
219
218
/* eslint-disable-next-line node/no-deprecated-api */
220
- if ( ! url . parse ( data . homepage ) . protocol ) {
219
+ if ( ! URL . canParse ( data . homepage ) ) {
221
220
data . homepage = 'http://' + data . homepage
222
221
}
223
222
}
0 commit comments