Skip to content

Commit 32a90db

Browse files
committed
get file ext from url with GET vars
1 parent 215372a commit 32a90db

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/FS.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ public static function ext($path)
372372
$path = preg_replace('#\?(.*)#', '', $path);
373373
}
374374

375-
return pathinfo($path, PATHINFO_EXTENSION);
375+
$ext = pathinfo($path, PATHINFO_EXTENSION);
376+
$ext = strtolower($ext);
377+
378+
return $ext;
376379
}
377380

378381
/**

tests/FileSystemTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,15 @@ public function testExt()
316316
isSame('', FS::ext(null));
317317
isSame('', FS::ext(false));
318318

319+
// URl
319320
isSame('txt', FS::ext('file.txt?some_var=123456'));
320321
isSame('txt', FS::ext('file.txt?some_var=123456?invalid=param'));
321322
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'));
322323
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'));
324+
325+
// to lower
326+
isSame('png', FS::ext('image.PNG'));
327+
isSame('png', FS::ext('image.PnG'));
323328
}
324329

325330
public function testBase()

0 commit comments

Comments
 (0)