@@ -227,7 +227,7 @@ public function install( $args, $assoc_args ) {
227227 add_filter ( 'upgrader_source_selection ' , $ filter , 10 );
228228 }
229229
230- // Check if the URL the URL is cachable and whitelist it then .
230+ // Add item to cache allowlist if it matches certain URL patterns .
231231 self ::maybe_cache ( $ slug , $ this ->item_type );
232232
233233 if ( $ file_upgrader ->install ( $ slug ) ) {
@@ -845,11 +845,11 @@ private function parse_url_host_component( $url, $component ) {
845845 }
846846
847847 /**
848- * Whitelist GitHub URLs for caching .
848+ * Add versioned GitHub URLs to cache allowlist .
849849 *
850850 * @param string $url The URL to check.
851851 */
852- public static function maybe_cache ( $ url , $ item_type ) {
852+ 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`
@@ -858,6 +858,8 @@ public static function maybe_cache( $url, $item_type ) {
858858 // cache archive URLs like `https://github.com/wp-cli-test/generic-example-plugin/archive/v0.1.0.zip`
859859 } elseif ( preg_match ( '#github\.com/[^/]+/([^/]+)/archive/(version/|)([^/]+)\.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 ) ) {
862+ WP_CLI ::get_http_cache_manager ()->whitelist_package ( $ url , $ item_type , $ matches [1 ], $ matches [2 ] );
861863 }
862864 }
863865
0 commit comments