File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1115,13 +1115,25 @@ public function get_url( bool $use_min_if_available = true ): string {
11151115 * Get the asset's full path - considering if minified exists.
11161116 *
11171117 * @since 1.4.6
1118+ * @since 1.4.7 When the path is a URL, return the URL.
11181119 *
11191120 * @param bool $use_min_if_available
11201121 *
11211122 * @return string
11221123 */
11231124 public function get_full_resource_path ( bool $ use_min_if_available = true ): string {
11241125 $ resource_path_data = $ this ->build_resource_path_data ();
1126+ if ( empty ( $ resource_path_data ['resource ' ] ) ) {
1127+ return '' ;
1128+ }
1129+
1130+ if (
1131+ str_starts_with ( $ resource_path_data ['resource ' ], 'http:// ' ) ||
1132+ str_starts_with ( $ resource_path_data ['resource ' ], 'https:// ' ) ||
1133+ str_starts_with ( $ resource_path_data ['resource ' ], '// ' )
1134+ ) {
1135+ return $ resource_path_data ['resource ' ];
1136+ }
11251137 $ resource = $ resource_path_data ['resource ' ];
11261138 $ resource_path = $ resource_path_data ['resource_path ' ];
11271139
Original file line number Diff line number Diff line change @@ -298,6 +298,14 @@ public function it_should_get_the_correct_url_when_wp_content_dir_and_wp_content
298298 }
299299 }
300300
301+ /**
302+ * @test
303+ */
304+ public function it_should_return_url_as_the_full_resource_path_when_the_path_is_a_url () {
305+ $ asset = Asset::add ( 'fake-script ' , 'https://example.com/fake.js ' );
306+ $ this ->assertEquals ( 'https://example.com/fake.js ' , $ asset ->get_full_resource_path () );
307+ }
308+
301309 public function constantProvider () {
302310 $ data = [
303311 [
You can’t perform that action at this time.
0 commit comments