11// Originally normalize-package-data
22
3- const url = require ( 'node:url' )
3+ const { URL } = require ( 'node:url' )
44const hostedGitInfo = require ( 'hosted-git-info' )
55const validateLicense = require ( 'validate-npm-package-license' )
66
@@ -123,8 +123,7 @@ function normalizeData (data, changes) {
123123 if ( typeof data . bugs === 'string' ) {
124124 if ( isEmail ( data . bugs ) ) {
125125 data . bugs = { email : data . bugs }
126- /* 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}` )
@@ -140,8 +139,7 @@ function normalizeData (data, changes) {
140139 const oldBugs = data . bugs
141140 data . bugs = { }
142141 if ( oldBugs . url ) {
143- /* eslint-disable-next-line node/no-deprecated-api */
144- if ( typeof ( oldBugs . url ) === 'string' && url . parse ( oldBugs . url ) . protocol ) {
142+ if ( URL . canParse ( oldBugs . url ) ) {
145143 data . bugs . url = oldBugs . url
146144 } else {
147145 changes ?. push ( 'bugs.url field must be a string url. Deleted.' )
@@ -216,8 +214,7 @@ function normalizeData (data, changes) {
216214 changes ?. push ( 'homepage field must be a string url. Deleted.' )
217215 delete data . homepage
218216 } else {
219- /* eslint-disable-next-line node/no-deprecated-api */
220- if ( ! url . parse ( data . homepage ) . protocol ) {
217+ if ( ! URL . canParse ( data . homepage ) ) {
221218 data . homepage = 'http://' + data . homepage
222219 }
223220 }
0 commit comments