@@ -853,12 +853,13 @@ protected static function maybe_cache( $url, $item_type ) {
853853 $ matches = [];
854854
855855 // cache release URLs like `https://github.com/wp-cli-test/generic-example-plugin/releases/download/v0.1.0/generic-example-plugin.0.1.0.zip`
856- if ( preg_match ( '#github\.com/[^/]+/([^/]+)/releases/download/tags/ ([^/]+)/(.+) \.zip# ' , $ url , $ matches ) ) {
857- WP_CLI ::get_http_cache_manager ()->whitelist_package ( $ url , $ item_type , $ matches [2 ], $ matches [3 ] );
856+ if ( preg_match ( '#github\.com/[^/]+/([^/]+)/releases/download/v? ([^/]+)/.+ \.zip# ' , $ url , $ matches ) ) {
857+ WP_CLI ::get_http_cache_manager ()->whitelist_package ( $ url , $ item_type , $ matches [1 ], $ matches [2 ] );
858858 // cache archive URLs like `https://github.com/wp-cli-test/generic-example-plugin/archive/v0.1.0.zip`
859- } elseif ( preg_match ( '#github\.com/[^/]+/([^/]+)/archive/(version/|)([^/]+)\.zip# ' , $ url , $ matches ) ) {
859+ } elseif ( preg_match ( '#github\.com/[^/]+/([^/]+)/archive/(version/|)v? ([^/]+)\.zip# ' , $ url , $ matches ) ) {
860860 WP_CLI ::get_http_cache_manager ()->whitelist_package ( $ url , $ item_type , $ matches [1 ], $ matches [3 ] );
861- } elseif ( preg_match ( '#api\.github\.com/repos/[^/]+/([^/]+)/zipball/([^/]+)# ' , $ url , $ matches ) ) {
861+ // cache release URLs like `https://api.github.com/repos/danielbachhuber/one-time-login/zipball/v0.4.0`
862+ } elseif ( preg_match ( '#api\.github\.com/repos/[^/]+/([^/]+)/zipball/v?([^/]+)# ' , $ url , $ matches ) ) {
862863 WP_CLI ::get_http_cache_manager ()->whitelist_package ( $ url , $ item_type , $ matches [1 ], $ matches [2 ] );
863864 }
864865 }
0 commit comments