@@ -264,17 +264,22 @@ public function getRelativeLinks()
264
264
*/
265
265
private function parseRelativeLinks ()
266
266
{
267
- $ matched = preg_match_all ('/[ Link|link] : *\<([^\>]+)\>; *rel=(\"[a-z]+\"|[a-z]+)/ ' , $ this ->responseHeaders , $ matches );
267
+ $ matched = preg_match_all ('/^( Link|link) : *(.*)$/m ' , $ this ->responseHeaders , $ matches );
268
268
if ($ matched ) {
269
269
for ($ i = 0 ; $ i < $ matched ; $ i ++) {
270
- $ rel = strtolower ($ matches [2 ][$ i ]);
271
- if (strpos ($ rel , '" ' ) === 0 ) {
272
- $ rel = substr ($ rel , 1 , strlen ($ rel ) - 2 );
273
- }
274
- if ($ rel === 'previous ' ) {
275
- $ rel = 'prev ' ;
270
+ $ links = explode (', ' , $ matches [2 ][$ i ]);
271
+ foreach ($ links as $ link ) {
272
+ if (preg_match ('/^\<([^\>]+)\>; *rel=([^ ]+)$/ ' , trim ($ link ), $ match )) {
273
+ $ rel = strtolower (utf8_decode ($ match [2 ]));
274
+ if ((strpos ($ rel , '" ' ) === 0 ) || (strpos ($ rel , '? ' ) === 0 )) {
275
+ $ rel = substr ($ rel , 1 , strlen ($ rel ) - 2 );
276
+ }
277
+ if ($ rel === 'previous ' ) {
278
+ $ rel = 'prev ' ;
279
+ }
280
+ $ this ->relativeLinks [$ rel ] = $ match [1 ];
281
+ }
276
282
}
277
- $ this ->relativeLinks [$ rel ] = $ matches [1 ][$ i ];
278
283
}
279
284
}
280
285
}
0 commit comments