@@ -5,52 +5,36 @@ export class MavenAccess {
55 const url = `/maven2/${ groupId . replaceAll ( "." , "/" ) } /${ artifactId
66 } /${ version } /${ artifactId } -${ version } .pom`;
77
8- const pom = await fetch ( url )
8+ return await fetch ( url )
99 . then ( ( response ) => response . text ( ) )
1010 . then ( ( str ) => {
1111 const parser = new XMLParser ( ) ;
1212 return parser . parse ( str ) . project ;
1313 } )
1414 . catch ( ( reason ) => console . error ( reason ) ) ;
15- return pom ;
1615 }
1716
18- async getArtifact ( groupId : string , artifactId : string ) : Promise < any > {
19- const url = `/maven2/${ groupId . replaceAll ( "." , "/" ) } /${ artifactId } /` ;
20-
21- const artifacts = await fetch ( url )
17+ private async retrieveAndProcessDirectory ( url : string ) : Promise < any > {
18+ return await fetch ( url )
2219 . then ( ( response ) => response . text ( ) )
2320 . then ( ( text ) => {
2421 const parser = new DOMParser ( ) ;
2522 return Array . from ( parser . parseFromString ( text , "text/html" )
26- . getElementById ( "contents" )
27- ?. querySelectorAll ( "A" ) ! )
28- . slice ( 1 ) . map ( a => a . textContent )
29- . filter ( link => link ?. endsWith ( "/" ) )
30- . map ( link => link ?. replace ( "/" , "" ) ) ;
23+ . getElementById ( "contents" )
24+ ?. querySelectorAll ( "A" ) ! )
25+ . slice ( 1 ) . map ( a => a . textContent )
26+ . filter ( link => link ?. endsWith ( "/" ) )
27+ . map ( link => link ?. replace ( "/" , "" ) ) ;
3128 } )
3229 . catch ( ( reason ) => console . error ( reason ) ) ;
30+ }
3331
34- return artifacts ;
32+ async getArtifact ( groupId : string , artifactId : string ) : Promise < any > {
33+ return this . retrieveAndProcessDirectory ( `/maven2/${ groupId . replaceAll ( "." , "/" ) } /${ artifactId } /` ) ;
3534 }
3635
3736 async getGroup ( groupId : string ) : Promise < any > {
38- const url = `/maven2/${ groupId . replaceAll ( "." , "/" ) } /` ;
39-
40- const group = await fetch ( url )
41- . then ( ( response ) => response . text ( ) )
42- . then ( ( text ) => {
43- const parser = new DOMParser ( ) ;
44- return Array . from ( parser . parseFromString ( text , "text/html" )
45- . getElementById ( "contents" )
46- ?. querySelectorAll ( "A" ) ! )
47- . slice ( 1 ) . map ( a => a . textContent )
48- . filter ( link => link ?. endsWith ( "/" ) )
49- . map ( link => link ?. replace ( "/" , "" ) ) ;
50- } )
51- . catch ( ( reason ) => console . error ( reason ) ) ;
52-
53- return group ;
37+ return this . retrieveAndProcessDirectory ( `/maven2/${ groupId . replaceAll ( "." , "/" ) } /` ) ;
5438 }
5539
5640
0 commit comments