ice.fo.utils
Version:
13 lines (12 loc) • 465 B
JavaScript
/* eslint-disable no-bitwise */
/**
* Doc: https://stackoverflow.com/questions/190852/how-can-i-get-file-extensions-with-javascript
"" --> ""
"name" --> ""
"name.txt" --> "txt"
".htpasswd" --> ""
"name.with.many.dots.myext" --> "myext"
*/
export default function getFilePathExtension(text) {
return text.slice((text.lastIndexOf('.') - 1 >>> 0) + 2);
}