File tree Expand file tree Collapse file tree 10 files changed +23
-12
lines changed Expand file tree Collapse file tree 10 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public function getEndPoint()
1919 {
2020 return Url::create (static ::$ endPoint )
2121 ->withQueryParameters ([
22- 'url ' => (string ) $ this ->response -> getUrl (),
22+ 'url ' => (string ) $ this ->getUrl (),
2323 'format ' => 'json ' ,
2424 'for ' => 'embed ' ,
2525 ]);
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function getEndPoint()
4242 {
4343 return Url::create ('http://api.embed.ly/1/oembed ' )
4444 ->withQueryParameters ([
45- 'url ' => (string ) $ this ->response -> getUrl (),
45+ 'url ' => (string ) $ this ->getUrl (),
4646 'format ' => 'json ' ,
4747 'key ' => $ this ->key ,
4848 ]);
Original file line number Diff line number Diff line change 1212abstract class EndPoint
1313{
1414 protected $ response ;
15+ protected $ url ;
1516 protected static $ pattern ;
1617 protected static $ endPoint ;
1718
@@ -25,16 +26,21 @@ public static function create(Adapter $adapter)
2526 if ($ response ->getUrl ()->match (static ::$ pattern )) {
2627 return new static ($ response );
2728 }
29+
30+ if ($ response ->getStartingUrl ()->match (static ::$ pattern )) {
31+ return new static ($ response , $ response ->getStartingUrl ());
32+ }
2833 }
2934
3035 /**
3136 * Constructor.
3237 *
3338 * @param Response $response
3439 */
35- protected function __construct (Response $ response )
40+ protected function __construct (Response $ response, Url $ url = null )
3641 {
3742 $ this ->response = $ response ;
43+ $ this ->url = $ url ;
3844 }
3945
4046 /**
@@ -44,8 +50,13 @@ public function getEndPoint()
4450 {
4551 return Url::create (static ::$ endPoint )
4652 ->withQueryParameters ([
47- 'url ' => (string ) $ this ->response -> getUrl (),
53+ 'url ' => (string ) $ this ->getUrl (),
4854 'format ' => 'json ' ,
4955 ]);
5056 }
57+
58+ public function getUrl ()
59+ {
60+ return $ this ->url ?: $ this ->response ->getUrl ();
61+ }
5162}
Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ class Facebook extends EndPoint implements EndPointInterface
1313 */
1414 public function getEndPoint ()
1515 {
16- if ($ this ->response -> getUrl ()->match (['*/videos/* ' , '/video.php ' ])) {
16+ if ($ this ->getUrl ()->match (['*/videos/* ' , '/video.php ' ])) {
1717 $ endPoint = Url::create ('https://www.facebook.com/plugins/video/oembed.json ' );
1818 } else {
1919 $ endPoint = Url::create ('https://www.facebook.com/plugins/post/oembed.json ' );
2020 }
2121
2222 return $ endPoint ->withQueryParameters ([
23- 'url ' => (string ) $ this ->response -> getUrl (),
23+ 'url ' => (string ) $ this ->getUrl (),
2424 'format ' => 'json ' ,
2525 ]);
2626 }
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function getEndPoint()
4242 {
4343 return Url::create ('http://open.iframe.ly/api/oembed ' )
4444 ->withQueryParameters ([
45- 'url ' => (string ) $ this ->response -> getUrl (),
45+ 'url ' => (string ) $ this ->getUrl (),
4646 'format ' => 'json ' ,
4747 'api_key ' => $ this ->key ,
4848 ]);
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Infogram extends EndPoint implements EndPointInterface
1717 */
1818 public function getEndPoint ()
1919 {
20- $ url = $ this ->response -> getUrl ()->withScheme ('https ' );
20+ $ url = $ this ->getUrl ()->withScheme ('https ' );
2121
2222 return Url::create (static ::$ endPoint )
2323 ->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Instagram extends EndPoint implements EndPointInterface
1717 */
1818 public function getEndPoint ()
1919 {
20- $ url = $ this ->response -> getUrl ()->withScheme ('http ' );
20+ $ url = $ this ->getUrl ()->withScheme ('http ' );
2121
2222 return Url::create (static ::$ endPoint )
2323 ->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class Jsbin extends EndPoint implements EndPointInterface
1414 */
1515 public function getEndPoint ()
1616 {
17- $ url = $ this ->response -> getUrl ()->withDirectoryPosition (2 , 'embed ' );
17+ $ url = $ this ->getUrl ()->withDirectoryPosition (2 , 'embed ' );
1818
1919 return Url::create (static ::$ endPoint )
2020 ->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Scribd extends EndPoint implements EndPointInterface
1717 */
1818 public function getEndPoint ()
1919 {
20- $ url = $ this ->response -> getUrl ()->withDirectoryPosition (0 , 'doc ' );
20+ $ url = $ this ->getUrl ()->withDirectoryPosition (0 , 'doc ' );
2121
2222 return Url::create (static ::$ endPoint )
2323 ->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public function getEndPoint()
1616 {
1717 return Url::create (static ::$ endPoint )
1818 ->withQueryParameters ([
19- 'url ' => (string ) $ this ->response -> getUrl ()->withQueryParameters ([]),
19+ 'url ' => (string ) $ this ->getUrl ()->withQueryParameters ([]),
2020 'format ' => 'json '
2121 ]);
2222 }
You can’t perform that action at this time.
0 commit comments