Make WordPress Core

Ticket #54797: 54797.diff

File 54797.diff, 1.2 KB (added by gziolo, 20 months ago)
  • src/wp-includes/blocks.php

     
    2020        if ( 0 !== strpos( $asset_handle_or_path, $path_prefix ) ) {
    2121                return $asset_handle_or_path;
    2222        }
    23         return substr(
     23        $path = substr(
    2424                $asset_handle_or_path,
    2525                strlen( $path_prefix )
    2626        );
     27        if ( strpos( $path, './' ) === 0 ) {
     28                $path = substr( $path, 2 );
     29        }
     30        return $path;
    2731}
    2832
    2933/**
  • tests/phpunit/tests/blocks/register.php

     
    122122         * @ticket 50263
    123123         */
    124124        public function test_removes_block_asset_path_prefix() {
     125                $result = remove_block_asset_path_prefix( 'file:block.js' );
     126
     127                $this->assertSame( 'block.js', $result );
     128        }
     129
     130        /**
     131         * @ticket 54797
     132         */
     133        public function test_removes_block_asset_path_prefix_and_current_directory() {
    125134                $result = remove_block_asset_path_prefix( 'file:./block.js' );
    126135
    127                 $this->assertSame( './block.js', $result );
     136                $this->assertSame( 'block.js', $result );
    128137        }
    129138
    130139        /**