@@ -286,7 +286,7 @@ function field<T>(
286286 for ( const [ failureMessage , fn ] of Object . entries (
287287 options ?. additionalChecks ?? { } ,
288288 ) ) {
289- if ( ! fn ) {
289+ if ( ! fn ( value as T ) ) {
290290 console . log ( `❌ ${ breadcrumbString } | ${ failureMessage } ` ) ;
291291 exitCode = 1 ;
292292 return ;
@@ -372,13 +372,30 @@ field(["license"], "string", {
372372field ( [ "repository" ] , "object" ) ;
373373field ( [ "repository" , "type" ] , "string" ) ;
374374const GIT_URL_PREFIX = "git+" ;
375- const GIT_URL_SUFFIX = "." ;
375+ const GIT_URL_SUFFIX = ".git " ;
376376field ( [ "repository" , "url" ] , "string" , {
377377 additionalChecks : {
378- [ `URL must be prefixed with \`${ GIT_URL_PREFIX } \`.` ] : ( url : string ) =>
379- url . startsWith ( GIT_URL_PREFIX ) ,
380- [ `URL must end with with \`.${ GIT_URL_SUFFIX } \`.` ] : ( url : string ) =>
381- url . endsWith ( GIT_URL_SUFFIX ) ,
378+ [ `GitHub URLs must have the approriate affixes.` ] : ( urlString : string ) => {
379+ const url = new URL ( urlString . replace ( / ^ g i t \+ / , "" ) ) ;
380+ if ( url . hostname === "github.com" ) {
381+ return (
382+ urlString . startsWith ( GIT_URL_PREFIX ) &&
383+ urlString . endsWith ( GIT_URL_SUFFIX )
384+ ) ;
385+ }
386+ return true ;
387+ } ,
388+ // `npm` does not handle `git+` for Codeberg URLs in its package listing pages.
389+ [ `Codeberg URLs must not have affixes.` ] : ( urlString : string ) => {
390+ const url = new URL ( urlString . replace ( / ^ g i t \+ / , "" ) ) ;
391+ if ( url . hostname === "codeberg.org" ) {
392+ return (
393+ ! urlString . startsWith ( GIT_URL_PREFIX ) &&
394+ ! urlString . endsWith ( GIT_URL_SUFFIX )
395+ ) ;
396+ }
397+ return true ;
398+ } ,
382399 "URL must parse." : ( url : string ) => {
383400 try {
384401 new URL ( url . slice ( ) ) ;
0 commit comments