@@ -236,6 +236,185 @@ describe('normalizeScmUrl', () => {
236236 expect ( normalizeScmUrl ( 'https://gitbox.apache.org/some/other/path' ) ) . toBeNull ( )
237237 } )
238238
239+ it ( 'recovers Apache gitweb ?p= urls with trailing `;`-separated gitweb params (a=, f=, h=, hb=)' , ( ) => {
240+ expect (
241+ normalizeScmUrl (
242+ 'https://gitbox.apache.org/repos/asf?p=lucene-solr.git;f=lucene/analysis/common' ,
243+ ) ,
244+ ) . toBe ( 'https://gitbox.apache.org/repos/asf/lucene-solr' )
245+ expect (
246+ normalizeScmUrl (
247+ 'https://git-wip-us.apache.org/repos/asf?p=flume.git;a=tree;h=refs/heads/trunk;hb=trunk' ,
248+ ) ,
249+ ) . toBe ( 'https://git-wip-us.apache.org/repos/asf/flume' )
250+ expect (
251+ normalizeScmUrl (
252+ 'https://git1-us-west.apache.org/repos/asf?p=lucene-solr.git;a=tree;f=lucene/analysis/uima' ,
253+ ) ,
254+ ) . toBe ( 'https://git1-us-west.apache.org/repos/asf/lucene-solr' )
255+ } )
256+
257+ it ( 'recovers Apache gitweb urls with a trailing subpath appended directly after .git' , ( ) => {
258+ expect (
259+ normalizeScmUrl ( 'https://gitbox.apache.org/repos/asf?p=hbase.git/hbase-build-configuration' ) ,
260+ ) . toBe ( 'https://gitbox.apache.org/repos/asf/hbase' )
261+ expect (
262+ normalizeScmUrl (
263+ 'https://gitbox.apache.org/repos/asf/ignite.git/ignite-parent-internal/ignite-core' ,
264+ ) ,
265+ ) . toBe ( 'https://gitbox.apache.org/repos/asf/ignite' )
266+ } )
267+
268+ it ( 'recovers git.apache.org repos declared at the bare root, without the /repos/asf/ prefix' , ( ) => {
269+ expect ( normalizeScmUrl ( 'http://git.apache.org/clerezza.git/' ) ) . toBe (
270+ 'https://git.apache.org/repos/asf/clerezza' ,
271+ )
272+ expect ( normalizeScmUrl ( 'http://git.apache.org/kafka.git' ) ) . toBe (
273+ 'https://git.apache.org/repos/asf/kafka' ,
274+ )
275+ } )
276+
277+ it ( 'recovers git.shibboleth.net gitweb ?p= urls, dropping trailing gitweb params' , ( ) => {
278+ expect ( normalizeScmUrl ( 'https://git.shibboleth.net/view/?p=java-opensaml.git' ) ) . toBe (
279+ 'https://git.shibboleth.net/view/?p=java-opensaml.git' ,
280+ )
281+ expect ( normalizeScmUrl ( 'https://git.shibboleth.net/view/?p=java-support.git;a=summary' ) ) . toBe (
282+ 'https://git.shibboleth.net/view/?p=java-support.git' ,
283+ )
284+ } )
285+
286+ it ( 'returns null for git.shibboleth.net urls with no recoverable repo name' , ( ) => {
287+ expect ( normalizeScmUrl ( 'https://git.shibboleth.net/view/' ) ) . toBeNull ( )
288+ } )
289+
290+ it ( 'recovers jogamp.org gitweb ?p= urls, dropping trailing subpath' , ( ) => {
291+ expect ( normalizeScmUrl ( 'http://jogamp.org/git/?p=gluegen.git/' ) ) . toBe (
292+ 'https://jogamp.org/git/?p=gluegen.git' ,
293+ )
294+ expect ( normalizeScmUrl ( 'http://jogamp.org/git/?p=jogl.git;a=summary' ) ) . toBe (
295+ 'https://jogamp.org/git/?p=jogl.git' ,
296+ )
297+ } )
298+
299+ it ( 'returns null for jogamp.org urls with no recoverable repo name' , ( ) => {
300+ expect ( normalizeScmUrl ( 'http://jogamp.org/git/' ) ) . toBeNull ( )
301+ } )
302+
303+ it ( 'recovers additional verified self-hosted GitLab/Gitea/cgit/sourcehut hosts' , ( ) => {
304+ expect ( normalizeScmUrl ( 'https://gitverse.ru/ys.kalyakin/commons-chain' ) ) . toBe (
305+ 'https://gitverse.ru/ys.kalyakin/commons-chain' ,
306+ )
307+ expect ( normalizeScmUrl ( 'https://git.sr.ht/~ajoberstar/grgit' ) ) . toBe (
308+ 'https://git.sr.ht/~ajoberstar/grgit' ,
309+ )
310+ expect ( normalizeScmUrl ( 'https://git.savannah.gnu.org/cgit/gettext' ) ) . toBe (
311+ 'https://git.savannah.gnu.org/cgit/gettext' ,
312+ )
313+ expect ( normalizeScmUrl ( 'https://oss.brouillard.fr/projects/jgitver' ) ) . toBe (
314+ 'https://oss.brouillard.fr/projects/jgitver' ,
315+ )
316+ } )
317+
318+ it ( 'normalizes Bitbucket Server clone and browse urls to the browse form' , ( ) => {
319+ expect (
320+ normalizeScmUrl ( 'https://ec.europa.eu/digital-building-blocks/code/scm/esig/dss.git' ) ,
321+ ) . toBe ( 'https://ec.europa.eu/digital-building-blocks/code/projects/esig/repos/dss' )
322+ expect ( normalizeScmUrl ( 'https://source.opendof.org/scm/core/core-java.git' ) ) . toBe (
323+ 'https://source.opendof.org/projects/core/repos/core-java' ,
324+ )
325+ } )
326+
327+ it ( 'returns null for unrecognized Bitbucket Server hosts' , ( ) => {
328+ expect ( normalizeScmUrl ( 'https://stash.openntf.org/scm/sbt/socialsdk.git' ) ) . toBeNull ( )
329+ } )
330+
331+ it ( 'recovers Azure DevOps _git urls, dropping trailing branch/path suffix' , ( ) => {
332+ expect ( normalizeScmUrl ( 'https://dev.azure.com/pumpitup/_git/pumpo-number-five' ) ) . toBe (
333+ 'https://dev.azure.com/pumpitup/_git/pumpo-number-five' ,
334+ )
335+ expect ( normalizeScmUrl ( 'https://dev.azure.com/myorg/myproject/_git/myrepo?path=/src' ) ) . toBe (
336+ 'https://dev.azure.com/myorg/myproject/_git/myrepo' ,
337+ )
338+ } )
339+
340+ it ( 'returns null for dev.azure.com urls with no _git marker' , ( ) => {
341+ expect ( normalizeScmUrl ( 'https://dev.azure.com/pumpitup' ) ) . toBeNull ( )
342+ } )
343+
344+ it ( 'recovers Aliyun Codeup urls, dropping the leading group-id segment' , ( ) => {
345+ expect (
346+ normalizeScmUrl (
347+ 'scm:git:git@codeup.aliyun.com:624f8224569a5e3edf2d4c1f/jihongbin12329/rock-1.0.git' ,
348+ ) ,
349+ ) . toBe ( 'https://codeup.aliyun.com/jihongbin12329/rock-1.0' )
350+ } )
351+
352+ it ( 'passes through android.googlesource.com urls unchanged' , ( ) => {
353+ expect ( normalizeScmUrl ( 'https://android.googlesource.com/platform/tools/base' ) ) . toBe (
354+ 'https://android.googlesource.com/platform/tools/base' ,
355+ )
356+ expect ( normalizeScmUrl ( 'https://android.googlesource.com/platform/tools/base.git/' ) ) . toBe (
357+ 'https://android.googlesource.com/platform/tools/base' ,
358+ )
359+ } )
360+
361+ it ( 'returns null for android.googlesource.com urls with no path' , ( ) => {
362+ expect ( normalizeScmUrl ( 'https://android.googlesource.com/' ) ) . toBeNull ( )
363+ } )
364+
365+ it ( 'recovers GitHub Pages project-page urls (owner.github.io/repo)' , ( ) => {
366+ expect ( normalizeScmUrl ( 'https://silentbalanceyh.github.io/vertx-zero/' ) ) . toBe (
367+ 'https://github.com/silentbalanceyh/vertx-zero' ,
368+ )
369+ expect ( normalizeScmUrl ( 'http://morn-team.github.io/morn-boot-projects/' ) ) . toBe (
370+ 'https://github.com/morn-team/morn-boot-projects' ,
371+ )
372+ } )
373+
374+ it ( 'recovers GitHub Pages user/org-page urls (bare owner.github.io, no path)' , ( ) => {
375+ expect ( normalizeScmUrl ( 'https://qyg2297248353.github.io' ) ) . toBe (
376+ 'https://github.com/qyg2297248353/qyg2297248353.github.io' ,
377+ )
378+ expect ( normalizeScmUrl ( 'http://openbaton.github.io' ) ) . toBe (
379+ 'https://github.com/openbaton/openbaton.github.io' ,
380+ )
381+ } )
382+
383+ it ( 'recovers a bare github.io host with owner/repo in the path (missing subdomain)' , ( ) => {
384+ expect ( normalizeScmUrl ( 'https://github.io/methrat0n/restruct' ) ) . toBe (
385+ 'https://github.com/methrat0n/restruct' ,
386+ )
387+ } )
388+
389+ it ( 'recovers the legacy owner.github.com Pages domain' , ( ) => {
390+ expect ( normalizeScmUrl ( 'https://zqq90.github.com/webit-script' ) ) . toBe (
391+ 'https://github.com/zqq90/webit-script' ,
392+ )
393+ expect ( normalizeScmUrl ( 'http://mhellkamp.github.com/endpoint/' ) ) . toBe (
394+ 'https://github.com/mhellkamp/endpoint' ,
395+ )
396+ } )
397+
398+ it ( 'returns null for GitHub Pages urls whose path still has an unresolved placeholder' , ( ) => {
399+ expect ( normalizeScmUrl ( 'http://dakusui.github.io/${project.name}' ) ) . toBeNull ( )
400+ } )
401+
402+ it ( 'returns null for a bare github.io host with no owner/repo path' , ( ) => {
403+ expect ( normalizeScmUrl ( 'https://github.io/' ) ) . toBeNull ( )
404+ expect ( normalizeScmUrl ( 'https://github.io/onlyowner' ) ) . toBeNull ( )
405+ } )
406+
407+ it ( 'recovers raw.githubusercontent.com and maven.pkg.github.com by remapping to github.com' , ( ) => {
408+ expect (
409+ normalizeScmUrl (
410+ 'https://raw.githubusercontent.com/crittercism/crittercism-android-agent/master/' ,
411+ ) ,
412+ ) . toBe ( 'https://github.com/crittercism/crittercism-android-agent' )
413+ expect ( normalizeScmUrl ( 'https://maven.pkg.github.com/CloudForgeCI/cfc-core' ) ) . toBe (
414+ 'https://github.com/cloudforgeci/cfc-core' ,
415+ )
416+ } )
417+
239418 it ( 'recovers git.eclipse.org cgit URLs, keeping the /c/ prefix and dropping trailing tree paths' , ( ) => {
240419 expect ( normalizeScmUrl ( 'http://git.eclipse.org/c/eclipselink/javax.persistence.git' ) ) . toBe (
241420 'https://git.eclipse.org/c/eclipselink/javax.persistence' ,
@@ -304,7 +483,6 @@ describe('normalizeScmUrl', () => {
304483 it ( 'still returns null for internal or non-allowlisted hosts' , ( ) => {
305484 expect ( normalizeScmUrl ( 'https://git.corp.adobe.com/team/project' ) ) . toBeNull ( )
306485 expect ( normalizeScmUrl ( 'https://gitlab.alibaba-inc.com/team/project' ) ) . toBeNull ( )
307- expect ( normalizeScmUrl ( 'https://android.googlesource.com/platform/tools/base' ) ) . toBeNull ( )
308486 } )
309487} )
310488
0 commit comments