File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class ResourceManager
1313 const MAP_RESOURCES = 'r ' ;
1414 const MAP_PUBLIC = 'p ' ;
1515 const MAP_COMPONENT = 'c ' ;
16+ const MAP_EXTERNAL = 'e ' ;
1617
1718 protected $ _type = self ::MAP_RESOURCES ;
1819 protected $ _mapOptions = [];
@@ -62,6 +63,11 @@ public static function inline()
6263 return new static (self ::MAP_INLINE , []);
6364 }
6465
66+ public static function external ()
67+ {
68+ return new static (self ::MAP_EXTERNAL , []);
69+ }
70+
6571 public static function component (DispatchableComponent $ component )
6672 {
6773 $ dispatch = Dispatch::instance ();
@@ -95,7 +101,7 @@ public static function component(DispatchableComponent $component)
95101 */
96102 public function getResourceUri ($ relativeFullPath ): ?string
97103 {
98- if ($ this ->isExternalUrl ($ relativeFullPath ))
104+ if ($ this ->_type == self :: MAP_EXTERNAL || $ this -> isExternalUrl ($ relativeFullPath ))
99105 {
100106 return $ relativeFullPath ;
101107 }
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ public function testComponent()
5454 'c/6/Packaged/Dispatch/Tests/TestComponents/DemoComponent/DemoComponent/a4197ed8/style.css ' ,
5555 $ manager ->getResourceUri ('style.css ' )
5656 );
57- Dispatch::instance ()->addComponentAlias ('\Packaged\Dispatch\Tests\TestComponents ' ,'' );
57+ Dispatch::instance ()->addComponentAlias ('\Packaged\Dispatch\Tests\TestComponents ' , '' );
5858 $ manager = ResourceManager::component ($ component );
5959 $ this ->assertEquals (
6060 'c/3/_/DemoComponent/DemoComponent/a4197ed8/style.css ' ,
@@ -105,6 +105,11 @@ public function testRequireInlineJs()
105105
106106 public function testIsExternalUrl ()
107107 {
108+ $ manager = ResourceManager::external ();
109+ $ this ->assertTrue ($ manager ->isExternalUrl ('http://www.google.com ' ));
110+ $ this ->assertFalse ($ manager ->isExternalUrl ('abhttp://www.google.com ' ));
111+
112+ //Check external still work on other resource types
108113 $ manager = ResourceManager::public ();
109114 $ this ->assertTrue ($ manager ->isExternalUrl ('http://www.google.com ' ));
110115 $ this ->assertFalse ($ manager ->isExternalUrl ('abhttp://www.google.com ' ));
You can’t perform that action at this time.
0 commit comments