Get next post page url

     

I want to get the next post page url   
Example  
domain.com/post-path/  
domain.com/post-path/2



domain.com/post-path/3 <-- this post has the next page link

but I don't want to continue. I want the crawler to stop when the path change



domain.com/post1-path/


This is the current code


// Get next page URL of the post   foreach($postNextPageUrlSelectors as $nextPageSelector) {   $attr = isset($nextPageSelector["attr"]) && $nextPageSelector["attr"] ? $nextPageSelector["attr"] : "href";   if ($nextPageUrl = $this->extractData($this->crawler $nextPageSelector["selector"] $attr