File tree Expand file tree Collapse file tree 3 files changed +28
-9
lines changed
Expand file tree Collapse file tree 3 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ public function getDescription()
6868 if ($ pages ) {
6969 $ page = current ($ pages );
7070
71- return strip_tags ($ page ['extract ' ]);
71+ return isset ( $ page [ ' extract ' ]) ? strip_tags ($ page ['extract ' ]) : null ;
7272 }
7373 }
7474
@@ -86,14 +86,16 @@ public function getImagesUrls()
8686
8787 $ imgs = [];
8888
89- foreach ($ page ['images ' ] as $ image ) {
90- switch (strrchr ($ image ['title ' ], '. ' )) {
91- case '.png ' :
92- case '.jpg ' :
93- case '.gif ' :
94- case '.jpeg ' :
95- $ imgs [] = $ image ['title ' ];
96- break ;
89+ if (isset ($ page ['images ' ])) {
90+ foreach ($ page ['images ' ] as $ image ) {
91+ switch (strrchr ($ image ['title ' ], '. ' )) {
92+ case '.png ' :
93+ case '.jpg ' :
94+ case '.gif ' :
95+ case '.jpeg ' :
96+ $ imgs [] = $ image ['title ' ];
97+ break ;
98+ }
9799 }
98100 }
99101
Original file line number Diff line number Diff line change @@ -536,5 +536,14 @@ private function setPath($path)
536536 $ this ->info ['file ' ] = isset ($ parts ['filename ' ]) ? $ parts ['filename ' ] : null ;
537537 $ this ->info ['extension ' ] = isset ($ parts ['extension ' ]) ? $ parts ['extension ' ] : null ;
538538 $ this ->info ['content ' ] = null ;
539+
540+ // bugfix /wiki/Supernatural_(U.S._TV_series) is parsed as:
541+ // path: /wiki/
542+ // file: Supernatural_(U.S
543+ // extension: _TV_series)
544+ if (!empty ($ this ->info ['extension ' ]) && !preg_match ('/^\w+$/ ' , $ this ->info ['extension ' ])) {
545+ $ this ->info ['file ' ] .= '. ' .$ this ->info ['extension ' ];
546+ $ this ->info ['extension ' ] = null ;
547+ }
539548 }
540549}
Original file line number Diff line number Diff line change @@ -53,4 +53,12 @@ public function testDomain()
5353 $ this ->assertSame ('domain ' , $ url ->getDomain ());
5454 $ this ->assertSame ('domain.com.au ' , $ url ->getDomain (1 ));
5555 }
56+
57+ public function testPathsWithDots ()
58+ {
59+ $ url = new Embed \Url ('https://en.wikipedia.org/wiki/Supernatural_(U.S._TV_series) ' );
60+ $ this ->assertNull ($ url ->getExtension ());
61+ $ this ->assertSame ('/wiki/Supernatural_(U.S._TV_series) ' , $ url ->getPath ());
62+ $ this ->assertSame ('Supernatural_(U.S._TV_series) ' , $ url ->getDirectoryPosition (1 ));
63+ }
5664}
You can’t perform that action at this time.
0 commit comments