Skip to content

Commit 0d8d970

Browse files
committed
complianted to releases api
1 parent 8b93ad0 commit 0d8d970

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/functions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public static function get_latest_vccw_url()
3636
$api = "https://api.github.com/repos/vccw-team/vccw/releases/latest";
3737
$body = json_decode( self::download( $api ) );
3838

39-
if ( $body ) {
39+
if ( ! empty( $body->assets[0] ) && ! empty( $body->assets[0]->browser_download_url ) ) {
40+
return $body->assets[0]->browser_download_url;
41+
} elseif ( $body ) {
4042
return $body->zipball_url;
4143
}
4244
}

tests/test-functions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
class Scaffold_VCCW_Test extends WP_UnitTestCase
44
{
5+
/**
6+
* Tests for the `Scaffold_VCCW::get_latest_vccw_url()`.
7+
*
8+
* @test
9+
* @since 1.3.0
10+
*/
11+
public function get_latest_vccw_url()
12+
{
13+
$url = Scaffold_VCCW::get_latest_vccw_url();
14+
$this->assertRegExp( '#^https://github.com/vccw-team/vccw/releases/download#', $url );
15+
}
16+
517
/**
618
* Tests for the `Scaffold_VCCW::rempty()`.
719
*

0 commit comments

Comments
 (0)