Skip to content

Commit dee4fe6

Browse files
authored
refactor: Optimize editor assets endpoint URL processing (#45358)
* refactor: Optimize editor assets endpoint URL processing Prefer the `str_starts_with` utility since it is available in PHP 8 and in a polyfill for WordPress 5.9.0 onward. Jetpack requires minimum of WordPress 6.7. - https://make.wordpress.org/core/2022/01/10/wordpress-5-9-and-php-8-0-8-1/ - https://github.com/Automattic/jetpack/blob/a5b0d2eb5fef8a5c59c95d0972c812ef2c6b994a/projects/plugins/jetpack/jetpack.php#L43 * changelog
1 parent 5aa3e87 commit dee4fe6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-block-editor-assets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private function is_allowed_plugin_handle( $handle ) {
380380
* @return string The absolute URL.
381381
*/
382382
public function make_url_absolute( $src ) {
383-
if ( ! empty( $src ) && strpos( $src, '/' ) === 0 && strpos( $src, '//' ) !== 0 ) {
383+
if ( ! empty( $src ) && str_starts_with( $src, '/' ) && ! str_starts_with( $src, '//' ) ) {
384384
return site_url( $src );
385385
}
386386
return $src;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: other
3+
4+
Editor assets endpoint: optimize URL processing

0 commit comments

Comments
 (0)