forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileTypeUtils.js
More file actions
1 lines (1 loc) · 1.27 KB
/
FileTypeUtils.js
File metadata and controls
1 lines (1 loc) · 1.27 KB
1
define(function(require,exports,module){function getExtension(filePath){let pathSplit=(filePath=filePath||"").split(".");return pathSplit&&pathSplit.length>1?pathSplit[pathSplit.length-1]:""}function isPDF(filePath){return"pdf"===getExtension(filePath).toLowerCase()}function isSVG(filePath){return"svg"===getExtension(filePath).toLowerCase()}function isImage(filePath){const extension=getExtension(filePath).toLowerCase();return["jpg","jpeg","png","gif","svg","webp","bmp","ico","avif"].includes(extension)}function isMarkdownFile(filePath){return["md","markdown","mdx"].includes(getExtension(filePath).toLowerCase())}function isHTMLFile(filePath){return["html","htm","xhtml"].includes(getExtension(filePath).toLowerCase())}function isPreviewableFile(filePath){return isSVG(filePath)||isMarkdownFile(filePath)||isHTMLFile(filePath)||isPDF(filePath)}function isServerRenderedFile(filePath){const extension=getExtension(filePath).toLowerCase();return["shtml","asp","aspx","php","jsp","jspx","cfm","cfc","rb","erb","py"].includes(extension)}exports.getExtension=getExtension,exports.isPDF=isPDF,exports.isSVG=isSVG,exports.isImage=isImage,exports.isHTMLFile=isHTMLFile,exports.isMarkdownFile=isMarkdownFile,exports.isPreviewableFile=isPreviewableFile,exports.isServerRenderedFile=isServerRenderedFile});