Skip to content

Commit

Permalink
resolve URL in every case
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanta94 committed Jun 13, 2024
1 parent d097063 commit 90936f7
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/Assets/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,6 @@ protected function build_asset_url(): string {
}
}

if ( ! file_exists( $root_path . $resource_path . $resource ) ) {
return false;
}

$url = $plugin_base_url . $resource_path . $resource;

/**
Expand All @@ -395,12 +391,6 @@ protected function build_asset_url(): string {
}

protected function build_min_asset_url( $original_url ): string {
$script_debug = defined( 'SCRIPT_DEBUG' ) && Utils::is_truthy( SCRIPT_DEBUG );

if ( $original_url && $script_debug ) {
return $original_url;
}

$resource = $this->get_file();
$root_path = $this->get_root_path();
$relative_path_to_assets = $this->is_vendor() ? '' : null;
Expand Down Expand Up @@ -469,12 +459,13 @@ protected function build_min_asset_url( $original_url ): string {
$minified_file_path = preg_replace( '#(.*).(js|css)#', '$1.min.$2', $resource_path . $resource );
}

$minified_abs_file_path = $root_path . $minified_file_path;
$script_debug = defined( 'SCRIPT_DEBUG' ) && Utils::is_truthy( SCRIPT_DEBUG );

codecept_debug( $minified_abs_file_path );
codecept_debug( $minified_file_path );
codecept_debug( $plugin_base_url );
codecept_debug( file_exists( $minified_abs_file_path ));
if ( $script_debug && file_exists( $root_path . $resource_path . $resource ) ) {
return $original_url;
}

$minified_abs_file_path = $root_path . $minified_file_path;

if ( ! file_exists( $minified_abs_file_path ) ) {
return $original_url;
Expand Down Expand Up @@ -791,7 +782,7 @@ public function get_url( bool $use_min_if_available = true ): string {
}

// If unminified is not available return the minified.
return $this->url ? $this->url : $this->min_url;
return $this->url;
}

/**
Expand Down

0 comments on commit 90936f7

Please sign in to comment.