@@ -28,16 +28,32 @@ class Updates {
28
28
29
29
async handle ( req , res ) {
30
30
this . log ( req . method , req . url , '...' )
31
- const segs = req . url . split ( '/' ) . filter ( Boolean )
32
- const [ account , repository , platform , version ] = segs
31
+ const segs = req . url . split ( / [ / ? ] / ) . filter ( Boolean )
32
+ const [ account , repository , platform , version , file ] = segs
33
33
if ( ! account || ! repository || ! platform || ! version ) {
34
34
notFound ( res )
35
+ } else if ( file === 'RELEASES' ) {
36
+ await this . handleReleases ( res , account , repository )
35
37
} else {
36
38
await this . handleUpdate ( res , account , repository , platform , version )
37
39
}
38
40
this . log ( req . method , req . url , res . statusCode )
39
41
}
40
42
43
+ async handleReleases ( res , account , repository ) {
44
+ const latest = await this . getLatest ( account , repository , 'win32' )
45
+ if ( ! latest ) return notFound ( res )
46
+
47
+ const url = `https://github.com/${ account } /${ repository } /releases/download/${
48
+ latest . version
49
+ } /RELEASES`
50
+ const rres = await fetch ( url )
51
+ const body = await rres . text ( )
52
+ const matches = body . match ( / [ ^ ] * \. n u p k g / gim)
53
+ const nuPKG = url . replace ( 'RELEASES' , matches [ 0 ] )
54
+ res . end ( body . replace ( matches [ 0 ] , nuPKG ) )
55
+ }
56
+
41
57
async handleUpdate ( res , account , repository , platform , version ) {
42
58
const latest = await this . getLatest ( account , repository , platform )
43
59
0 commit comments