public function testSlashesAreProperlyPrepended()
 {
     $slashTestOne = FacebookUrlManipulator::forceSlashPrefix('foo');
     $slashTestTwo = FacebookUrlManipulator::forceSlashPrefix('/foo');
     $slashTestThree = FacebookUrlManipulator::forceSlashPrefix('foo/bar');
     $slashTestFour = FacebookUrlManipulator::forceSlashPrefix('/foo/bar');
     $slashTestFive = FacebookUrlManipulator::forceSlashPrefix(null);
     $slashTestSix = FacebookUrlManipulator::forceSlashPrefix('');
     $this->assertEquals('/foo', $slashTestOne);
     $this->assertEquals('/foo', $slashTestTwo);
     $this->assertEquals('/foo/bar', $slashTestThree);
     $this->assertEquals('/foo/bar', $slashTestFour);
     $this->assertEquals(null, $slashTestFive);
     $this->assertEquals('', $slashTestSix);
 }
 /**
  * Generate and return the URL for this request.
  *
  * @return string
  */
 public function getUrl()
 {
     $this->validateMethod();
     $graphVersion = FacebookUrlManipulator::forceSlashPrefix($this->graphVersion);
     $endpoint = FacebookUrlManipulator::forceSlashPrefix($this->getEndpoint());
     $url = $graphVersion . $endpoint;
     if ($this->getMethod() !== 'POST') {
         $params = $this->getParams();
         $url = FacebookUrlManipulator::appendParamsToUrl($url, $params);
     }
     return $url;
 }
 /**
  * Generates a pagination URL based on a cursor.
  *
  * @param string $direction The direction of the page: next|previous
  *
  * @return string|null
  *
  * @throws FacebookSDKException
  */
 public function getPaginationUrl($direction)
 {
     $this->validateForPagination();
     // Do we have a paging URL?
     if (isset($this->metaData['paging'][$direction])) {
         // Graph returns the full URL with all the original params.
         // We just want the endpoint though.
         $pageUrl = $this->metaData['paging'][$direction];
         return FacebookUrlManipulator::baseGraphUrlEndpoint($pageUrl);
     }
     // Do we have a cursor to work with?
     $cursorDirection = $direction === 'next' ? 'after' : 'before';
     $cursor = $this->getCursor($cursorDirection);
     if (!$cursor) {
         return null;
     }
     // If we don't know the ID of the parent node, this ain't gonna work.
     if (!$this->parentEdgeEndpoint) {
         return null;
     }
     // We have the parent node ID, paging cursor & original request.
     // These were the ingredients chosen to create the perfect little URL.
     $pageUrl = $this->parentEdgeEndpoint . '?' . $cursorDirection . '=' . urlencode($cursor);
     // Pull in the original params
     $originalUrl = $this->request->getUrl();
     $pageUrl = FacebookUrlManipulator::mergeUrlParams($originalUrl, $pageUrl);
     return FacebookUrlManipulator::forceSlashPrefix($pageUrl);
 }