@@ -2,7 +2,10 @@ import { describe, expect, it } from 'vitest'
22
33import {
44 GRADLE_PLUGIN_PORTAL_BASE_URL ,
5+ JITPACK_BASE_URL ,
56 MAVEN_CENTRAL_BASE_URL ,
7+ isJitpackNamespace ,
8+ jitpackPageUrl ,
69 resolveRegistryBaseUrl ,
710 resolveRegistryPageUrl ,
811 resolveRegistryPageUrlFromBase ,
@@ -150,19 +153,19 @@ describe('resolveRegistryBaseUrl', () => {
150153 )
151154 } )
152155
153- it ( 'returns JitPack for io.github namespace' , ( ) => {
154- expect ( resolveRegistryBaseUrl ( 'io.github.resilience4j' ) ) . toBe ( 'https://jitpack.io' )
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 )
155158 } )
156159
157- it ( 'returns JitPack for bare io.github (exact match) ' , ( ) => {
158- expect ( resolveRegistryBaseUrl ( 'io.github' ) ) . toBe ( 'https://jitpack.io' )
160+ it ( 'returns Maven Central for bare io.github' , ( ) => {
161+ expect ( resolveRegistryBaseUrl ( 'io.github' ) ) . toBe ( MAVEN_CENTRAL_BASE_URL )
159162 } )
160163
161- it ( 'returns JitPack for com.github namespace' , ( ) => {
162- expect ( resolveRegistryBaseUrl ( 'com.github.ben-manes' ) ) . toBe ( 'https://jitpack.io' )
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 )
163166 } )
164167
165- it ( 'does not match io.githubfoo — prefix boundary must end at a dot ' , ( ) => {
168+ it ( 'returns Maven Central for io.githubfoo (no dot boundary) ' , ( ) => {
166169 expect ( resolveRegistryBaseUrl ( 'io.githubfoo' ) ) . toBe ( MAVEN_CENTRAL_BASE_URL )
167170 } )
168171} )
@@ -192,21 +195,17 @@ describe('resolveRegistryPageUrl', () => {
192195 )
193196 } )
194197
195- it ( 'returns JitPack browse URL for io.github' , ( ) => {
198+ it ( 'returns Maven Central URL for io.github (Central is primary) ' , ( ) => {
196199 expect ( resolveRegistryPageUrl ( 'io.github.resilience4j' , 'resilience4j-core' ) ) . toBe (
197- 'https://jitpack.io/# resilience4j/resilience4j-core' ,
200+ 'https://central.sonatype.com/artifact/io.github. resilience4j/resilience4j-core' ,
198201 )
199202 } )
200203
201- it ( 'returns JitPack browse URL for com.github' , ( ) => {
204+ it ( 'returns Maven Central URL for com.github (Central is primary) ' , ( ) => {
202205 expect ( resolveRegistryPageUrl ( 'com.github.ben-manes' , 'caffeine' ) ) . toBe (
203- 'https://jitpack.io/# ben-manes/caffeine' ,
206+ 'https://central.sonatype.com/artifact/com.github. ben-manes/caffeine' ,
204207 )
205208 } )
206-
207- it ( 'returns JitPack browse URL for bare io.github prefix without leaking the prefix into the path' , ( ) => {
208- expect ( resolveRegistryPageUrl ( 'io.github' , 'some-lib' ) ) . toBe ( 'https://jitpack.io/#/some-lib' )
209- } )
210209} )
211210
212211describe ( 'resolveRegistryPageUrlFromBase' , ( ) => {
@@ -236,4 +235,55 @@ describe('resolveRegistryPageUrlFromBase', () => {
236235 ) ,
237236 ) . toBe ( 'https://plugins.gradle.org/m2/io/github/trueangle/gradle-plugin/' )
238237 } )
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+ } )
239289} )
0 commit comments