11import { describe , expect , it } from 'vitest'
22
33import {
4+ GRADLE_PLUGIN_PORTAL_BASE_URL ,
5+ JITPACK_BASE_URL ,
46 MAVEN_CENTRAL_BASE_URL ,
7+ isJitpackNamespace ,
8+ jitpackPageUrl ,
59 resolveRegistryBaseUrl ,
610 resolveRegistryPageUrl ,
711 resolveRegistryPageUrlFromBase ,
@@ -148,6 +152,22 @@ describe('resolveRegistryBaseUrl', () => {
148152 'https://repo.jenkins-ci.org/public' ,
149153 )
150154 } )
155+
156+ it ( 'returns Maven Central for io.github namespace (JitPack is a fallback, not primary)' , ( ) => {
157+ expect ( resolveRegistryBaseUrl ( 'io.github.resilience4j' ) ) . toBe ( MAVEN_CENTRAL_BASE_URL )
158+ } )
159+
160+ it ( 'returns Maven Central for bare io.github' , ( ) => {
161+ expect ( resolveRegistryBaseUrl ( 'io.github' ) ) . toBe ( MAVEN_CENTRAL_BASE_URL )
162+ } )
163+
164+ it ( 'returns Maven Central for com.github namespace (JitPack is a fallback, not primary)' , ( ) => {
165+ expect ( resolveRegistryBaseUrl ( 'com.github.ben-manes' ) ) . toBe ( MAVEN_CENTRAL_BASE_URL )
166+ } )
167+
168+ it ( 'returns Maven Central for io.githubfoo (no dot boundary)' , ( ) => {
169+ expect ( resolveRegistryBaseUrl ( 'io.githubfoo' ) ) . toBe ( MAVEN_CENTRAL_BASE_URL )
170+ } )
151171} )
152172
153173describe ( 'resolveRegistryPageUrl' , ( ) => {
@@ -174,6 +194,18 @@ describe('resolveRegistryPageUrl', () => {
174194 'https://central.sonatype.com/artifact/org.apache.commons/commons-lang3' ,
175195 )
176196 } )
197+
198+ it ( 'returns Maven Central URL for io.github (Central is primary)' , ( ) => {
199+ expect ( resolveRegistryPageUrl ( 'io.github.resilience4j' , 'resilience4j-core' ) ) . toBe (
200+ 'https://central.sonatype.com/artifact/io.github.resilience4j/resilience4j-core' ,
201+ )
202+ } )
203+
204+ it ( 'returns Maven Central URL for com.github (Central is primary)' , ( ) => {
205+ expect ( resolveRegistryPageUrl ( 'com.github.ben-manes' , 'caffeine' ) ) . toBe (
206+ 'https://central.sonatype.com/artifact/com.github.ben-manes/caffeine' ,
207+ )
208+ } )
177209} )
178210
179211describe ( 'resolveRegistryPageUrlFromBase' , ( ) => {
@@ -193,4 +225,65 @@ describe('resolveRegistryPageUrlFromBase', () => {
193225 resolveRegistryPageUrlFromBase ( 'com.google.firebase' , 'firebase-analytics' , googleMavenUrl ) ,
194226 ) . toBe ( 'https://maven.google.com/web/index.html#com.google.firebase:firebase-analytics' )
195227 } )
228+
229+ it ( 'returns Gradle Plugin Portal path when resolvedBaseUrl is Gradle Plugin Portal' , ( ) => {
230+ expect (
231+ resolveRegistryPageUrlFromBase (
232+ 'io.github.trueangle' ,
233+ 'gradle-plugin' ,
234+ GRADLE_PLUGIN_PORTAL_BASE_URL ,
235+ ) ,
236+ ) . toBe ( 'https://plugins.gradle.org/m2/io/github/trueangle/gradle-plugin/' )
237+ } )
238+
239+ it ( 'returns JitPack browse URL when resolvedBaseUrl is JitPack' , ( ) => {
240+ expect (
241+ resolveRegistryPageUrlFromBase ( 'io.github.trueangle' , 'gradle-plugin' , JITPACK_BASE_URL ) ,
242+ ) . toBe ( 'https://jitpack.io/#trueangle/gradle-plugin' )
243+ } )
244+ } )
245+
246+ describe ( 'isJitpackNamespace' , ( ) => {
247+ it ( 'returns true for io.github.* packages' , ( ) => {
248+ expect ( isJitpackNamespace ( 'io.github.resilience4j' ) ) . toBe ( true )
249+ } )
250+
251+ it ( 'returns true for bare io.github' , ( ) => {
252+ expect ( isJitpackNamespace ( 'io.github' ) ) . toBe ( true )
253+ } )
254+
255+ it ( 'returns true for com.github.* packages' , ( ) => {
256+ expect ( isJitpackNamespace ( 'com.github.ben-manes' ) ) . toBe ( true )
257+ } )
258+
259+ it ( 'returns true for bare com.github' , ( ) => {
260+ expect ( isJitpackNamespace ( 'com.github' ) ) . toBe ( true )
261+ } )
262+
263+ it ( 'returns false for io.githubfoo (no dot boundary)' , ( ) => {
264+ expect ( isJitpackNamespace ( 'io.githubfoo' ) ) . toBe ( false )
265+ } )
266+
267+ it ( 'returns false for unrelated namespaces' , ( ) => {
268+ expect ( isJitpackNamespace ( 'org.apache.commons' ) ) . toBe ( false )
269+ expect ( isJitpackNamespace ( 'io.jenkins.plugins' ) ) . toBe ( false )
270+ } )
271+ } )
272+
273+ describe ( 'jitpackPageUrl' , ( ) => {
274+ it ( 'strips io.github. prefix from groupId' , ( ) => {
275+ expect ( jitpackPageUrl ( 'io.github.resilience4j' , 'resilience4j-core' ) ) . toBe (
276+ 'https://jitpack.io/#resilience4j/resilience4j-core' ,
277+ )
278+ } )
279+
280+ it ( 'strips com.github. prefix from groupId' , ( ) => {
281+ expect ( jitpackPageUrl ( 'com.github.ben-manes' , 'caffeine' ) ) . toBe (
282+ 'https://jitpack.io/#ben-manes/caffeine' ,
283+ )
284+ } )
285+
286+ it ( 'handles bare io.github with no sub-namespace' , ( ) => {
287+ expect ( jitpackPageUrl ( 'io.github' , 'some-lib' ) ) . toBe ( 'https://jitpack.io/#/some-lib' )
288+ } )
196289} )
0 commit comments