Skip to content

Commit

Permalink
get file ext from url with GET vars
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Feb 26, 2016
1 parent 215372a commit 32a90db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/FS.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ public static function ext($path)
$path = preg_replace('#\?(.*)#', '', $path);
}

return pathinfo($path, PATHINFO_EXTENSION);
$ext = pathinfo($path, PATHINFO_EXTENSION);
$ext = strtolower($ext);

return $ext;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/FileSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,15 @@ public function testExt()
isSame('', FS::ext(null));
isSame('', FS::ext(false));

// URl
isSame('txt', FS::ext('file.txt?some_var=123456'));
isSame('txt', FS::ext('file.txt?some_var=123456?invalid=param'));
isSame('php', FS::ext('http://demo.jbzoo.com/sites/phones/smartfony.php?logic=and&exact=0&controller=search&option=com_zoo&task=filter&type=phone&app_id=1&Itemid=101'));
isSame('', FS::ext('http://demo.jbzoo.com/sites/phones/smartfony?logic=and&exact=0&controller=search&option=com_zoo&task=filter&type=phone&app_id=1&Itemid=101'));

// to lower
isSame('png', FS::ext('image.PNG'));
isSame('png', FS::ext('image.PnG'));
}

public function testBase()
Expand Down

0 comments on commit 32a90db

Please sign in to comment.