{"id":15653184,"url":"https://github.com/silverwind/file-extension","last_synced_at":"2025-08-08T08:54:16.124Z","repository":{"id":31406459,"uuid":"34969743","full_name":"silverwind/file-extension","owner":"silverwind","description":"Get the extension of a given filename or path","archived":false,"fork":false,"pushed_at":"2018-05-31T18:22:15.000Z","size":131,"stargazers_count":30,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-30T16:06:40.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silverwind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-03T01:34:44.000Z","updated_at":"2023-07-23T18:51:16.000Z","dependencies_parsed_at":"2022-09-04T21:21:29.496Z","dependency_job_id":null,"html_url":"https://github.com/silverwind/file-extension","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/silverwind/file-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Ffile-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Ffile-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Ffile-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Ffile-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silverwind","download_url":"https://codeload.github.com/silverwind/file-extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Ffile-extension/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269393651,"owners_count":24409756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T12:44:53.827Z","updated_at":"2025-08-08T08:54:16.068Z","avatar_url":"https://github.com/silverwind.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# file-extension\n[![](https://img.shields.io/npm/v/file-extension.svg?style=flat)](https://www.npmjs.org/package/file-extension) [![](https://img.shields.io/npm/dm/file-extension.svg)](https://www.npmjs.org/package/file-extension) [![](https://api.travis-ci.org/silverwind/file-extension.svg?style=flat)](https://travis-ci.org/silverwind/file-extension)\n\u003e Get the extension of a given filename or path\n\nDifferences to [`path.extname`](https://nodejs.org/api/path.html#path_path_extname_path):\n\n* Treats dotfiles as extension (`.eslintrc` =\u003e `eslintrc`)\n* Treats extensionless files as extension (`Makefile` =\u003e `makefile`)\n* Doesn't include the dot in the extension (`package.json` =\u003e `json`)\n* Returns lowercase by default (`LICENCE` =\u003e `licence`)\n\nWorks in Node.js and the browser. The module's size is currently 267 bytes gzipped.\n\n## Installation\n#### Node.js\n```\n$ npm install --save file-extension\n```\n#### Browser\n```html\n\u003cscript src=\"file-extension.js\"\u003e\u003c/script\u003e\n\u003c!-- Available as global `fileExtension` --\u003e\n```\n## Example\n```js\nvar fileExtension = require('file-extension'); // Skip this in the browser\n\n// Case insensitive\nfileExtension('file.zip');          //=\u003e 'zip'\nfileExtension('.Dockerfile');       //=\u003e 'dockerfile'\nfileExtension('file');              //=\u003e 'file'\nfileExtension('.file.tar');         //=\u003e 'tar'\n\n// Or with case preserved\nfileExtension('.Vagrantfile', {preserveCase: true}); //=\u003e 'Vagrantfile'\nfileExtension('INDEX.HTML', {preserveCase: true});   //=\u003e 'HTML'\n```\n\n## API\n### fileExtension(filename, [options])\n- `filename` {String} The file name. Required.\n- `options` {Object} Options object.\n\n#### Options\n- `preserveCase` {Boolean} Whether case should be preserved. Default: false.\n\n© [silverwind](https://github.com/silverwind), distributed under BSD licence\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Ffile-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilverwind%2Ffile-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Ffile-extension/lists"}