11// Originally normalize-package-data
22
3- const url = require ( 'node:url' )
43const hostedGitInfo = require ( 'hosted-git-info' )
54const validateLicense = require ( 'validate-npm-package-license' )
65
@@ -124,7 +123,7 @@ function normalizeData (data, changes) {
124123 if ( isEmail ( data . bugs ) ) {
125124 data . bugs = { email : data . bugs }
126125 /* eslint-disable-next-line node/no-deprecated-api */
127- } else if ( url . parse ( data . bugs ) . protocol ) {
126+ } else if ( URL . canParse ( data . bugs ) ) {
128127 data . bugs = { url : data . bugs }
129128 } else {
130129 changes ?. push ( `Bug string field must be url, email, or {email,url}` )
@@ -141,7 +140,7 @@ function normalizeData (data, changes) {
141140 data . bugs = { }
142141 if ( oldBugs . url ) {
143142 /* 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 ) ) {
145144 data . bugs . url = oldBugs . url
146145 } else {
147146 changes ?. push ( 'bugs.url field must be a string url. Deleted.' )
@@ -217,7 +216,7 @@ function normalizeData (data, changes) {
217216 delete data . homepage
218217 } else {
219218 /* eslint-disable-next-line node/no-deprecated-api */
220- if ( ! url . parse ( data . homepage ) . protocol ) {
219+ if ( ! URL . canParse ( data . homepage ) ) {
221220 data . homepage = 'http://' + data . homepage
222221 }
223222 }
0 commit comments